Identifiers in C programming are the case-sensitive names given to the variables, functions, array, etc to identify them.
Example:
float length = 2.3;
int max;
double myArray[10];
In above example length
, max
and myArray
are the identifiers.
Rules for naming an identifiers
- The first character of an identifiers should be a alphabet(a-z , A-Z) or underscore (_).
- Keywords are not allowed to be used as Identifiers.
- Identifiers should not be of length more than 31 characters.
- Commas or spaces are not allowed within an identifier.
- Identifiers are case-sensitive so UPPERCASE and lowercase are treated as different name. For example: APPLE, Apple and apple are three different identifiers.
Example:
123Hello invalid
int invalid
main invalid
_hello valid
Hello valid
Hello123 valid
hello.var invalid
hello var invalid