Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the conditions for user identification to conform to the law in C language?

Shulou Source: shulou.com Published: 2022-06-01 01:35:48 10月04日 Update

This article mainly introduces "what are the conditions for user identification in C language to comply with the law". In daily operation, I believe that many people have doubts about the conditions for user identification to comply with the law in C language. I have consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the questions of "what are the conditions for user identification in C language to comply with the law?" Next, please follow the editor to study!

The user ID conforms to the conditions of the law: 1, it can only be composed of letters (A to Z), numbers (0 to 9) and the underscore "_", and the first character must be a letter or an underscore, not a number; 2, identifiers cannot use keywords (reserved words).

The operating environment of this tutorial: windows7 system, C99 version, Dell G3 computer.

User identifier:

An identifier defined by the user as needed. It is generally used to name variables, functions, arrays, etc. If the user identifier is the same as the keyword, there will be an error at compile time; if it is the same as the predefined identifier, there will be no error at compile time, but the original meaning of the predefined identifier will be lost, or it may cause an error in the result. therefore, predefined identifiers are generally not used as user identifiers.

User identifiers should generally follow the following naming rules:

1. Identifiers can only consist of letters (AbeliZ, aqz), numbers (0,9) and underscores (_), and the first character must be a letter or underscore, not a number.

2. Keywords have special meaning and cannot be used as identifiers

The following are legal identifiers:

A, x, x3, BOOK_1, sum5

The following is an illegal identifier:

3s cannot start with a number

Illegal character appears in sprinter *

-3x cannot start with a minus sign (-)

Illegal character minus sign appears in bowy-1 (-)

Note:

In C, identifiers are case-sensitive; for example, BOOK and book are two different identifiers.

The length of the identifier should be within 31 characters in c89 and 63 characters in c99.

It is best to take a string with a certain meaning to facilitate memory and understanding of the custom identifier.

Although identifiers can be defined by programmers at will, identifiers are symbols used to identify a certain quantity, so naming should have corresponding meaning as far as possible so that it can be read and understood "as the name implies".

At this point, the study of "what are the conditions for user identification in C language to comply with the law" is over. I hope to be able to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Identity identifier user character legal condition language letter number underscore learning key keyword meaning same minus sign beginning more help compilation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Apple MariaDB Microsoft Huawei