Identifiers are user-defined names (with a sequence of letters and digits) given to the variables, arrays, functions, structures, unions, etc.
For example: In terms of computers, it uses a range of addresses to identify the data. But as a programmer, we can’t get those addresses before program execution. so rather than using addresses, we use identifiers.
Rules of identifiers :
In order to remove the ambiguity during the compilation process, C creators imposed a set of rules on identifiers. They are :
- The first character must start with a letter (A to Z) or (a to z) or with an underscore (_).
- An identifier should contain only letters (A to Z) or (a-z) or digits (0 to 9) or an underscore (_).
- Identifiers are case-sensitive i.e. “EXAMPLE“, “example“, “Example“, “eXample” are four different identifiers.
- Identifiers should not contain any ‘special characters‘ & ‘white space characters‘ except underscore.
Special characters
Whitespace characters
Keywords are not allowed to use as identifiers because keywords are reserved words.
Valid identifiers:
- _dataoverride
- c_tutorials1
- jamesbond007
- Final__Example
Invalid identifiers:
- 123example
- @example2
- data override
- float (It is invalid because the float is a keyword)
Refer “page 192 section A2.3 Identifiers” in “The C programming language by Dennis M Ritchie & Brian W. Kernighan”