C language stipulates that identifiers can only be composed of three characters: letters, numbers and underscores, and the first character must be a letter or underscore, and the identifier cannot It is a keyword of C language.
Related introduction:
What is an identifier?
In programming languages, identifiers are names used by users when programming. Variables, constants, functions, and statement blocks all have names. They are a symbol used to identify a certain entity and are a reference to variables. names, function names, labels, and various other user-defined object naming.
Naming specifications for identifiers in C language:
1. Identifiers consist of letters, numbers, and underscores, and the first letter cannot be a number. (Punctuation characters, such as @, $ and %, are not allowed in C identifiers.)
2. Identifiers are case-sensitive, that is, they are strictly case-sensitive. Generally use lowercase for variable names and uppercase for symbolic constants. (Note: Letters in C language are case-sensitive, so score, Score, and SCORE represent three different identifiers respectively)
3. C keywords cannot be used as user identifiers, for example: if, for, while, etc. (Note: The identifier cannot be the same as a C language keyword, nor can it have the same name as a user-defined function or C language library function. For is OK because it is case-sensitive.) C language keywords (32 5 7)
4. The length of the identifier is determined by the compilation system on the machine. The general limit is 8 characters. (Note: The 8-character length limit is the C89 standard. The C99 standard has expanded the length. In fact, most industrial standards longer).
5. Identifier naming should be such that "the meaning is known by the name", for example, length (foreign language: length), sum, total (foreign language: sum), pi (foreign language: pi)
Recommended tutorial: C language tutorial
The above is the detailed content of What does an identifier in C language consist of?. For more information, please follow other related articles on the PHP Chinese website!