Conditions for legal user identifiers: 1. It can only consist of letters (A to Z, a to z), numbers (0 to 9) and the underscore "_", and the first character must be a letter or underscore, cannot be a number; 2. Keywords (reserved words) cannot be used in identifiers.
The operating environment of this tutorial: windows7 system, c99 version, Dell G3 computer.
User identifier:
An identifier defined by the user according to their needs. Generally used to name variables, functions, arrays, etc. If the user identifier is the same as a keyword, an error will occur during compilation; if it is the same as a predefined identifier, no error will occur during compilation, but the original meaning of the predefined identifier will be lost or the result will be wrong, so predefined identifiers Generally not used as a user identifier.
User identifiers should generally follow the following naming rules:
1. Identifiers can only consist of letters (A~Z, a~ z), 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 are illegal identifiers:
3s
Cannot start with a number
s*T
An illegal character appears*
-3x
cannot begin with a minus sign (-)
bowy-1
appears Illegal character minus sign (-)
Note:
In C language, identifiers are case-sensitive; for example, BOOK
and book
are two different identifiers.
The length of the identifier, c89 stipulates that it should be within 31 characters, and c99 stipulates that it should be within 63 characters;
It is best to use a custom identifier A string with a certain meaning that is easy to remember and understand.
Although identifiers can be defined at will by programmers, identifiers are symbols used to identify a certain quantity. Therefore, the naming should have corresponding meanings as much as possible to facilitate reading and understanding, and be "just as the name implies".
Related recommendations: "C Language Video Tutorial"
The above is the detailed content of What are the conditions for a legal user identifier?. For more information, please follow other related articles on the PHP Chinese website!