C Programming Identifiers

Last modified by Microchip on 2023/11/09 09:07

Identifier
An identifier is a name given to a program element such as a variablefunction, or array. This name may be used to refer to the program element without knowing its specific location in memory.

Identifiers in C must be strings of characters from the valid C character set, which includes all the letters of the English alphabet (both upper and lower case), the numbers 0-9, and the underscore. The first character of an identifier must NOT be a number and under no circumstances may an identifier contain a space.Identifier

All identifiers are case-sensitive, so you can have two identical identifiers except for the case of the first character and they will be considered two completely different identifiers.

1
2
int myVar;            // This variable...
int MyVar;            // ...is NOT the same as this variable.

Also, according to the ANSI C standard, only the first 31 characters of an identifier are significant. So, if you had two 32-character identifiers differing only in the last character, some compilers would not recognize them as being different. With that said, most modern compilers far exceed the limit of 31 characters, allowing very long identifiers with many more significant characters.

1
2
int abcdefghijklmnopqrstuvwxyz01234X;    // This variable...            
int abcdefghijklmnopqrstuvwxyz01234Y;    // ...might be indistinguishable from this one