In this tutorial, you will learn about C identifiers and how to use them in the C programming language.
C Identifiers refer to the name given to the entities such as variables, functions, arrays, structures, unions, labels, etc. An Identifier name can be composed of letters such as uppercase letters, lowercase letters, special characters, underscore, and digits. However, the starting character should be either a character or underscore.
There are 52 alphabetic characters (uppercase and lowercase), underscore characters, and 10 numerical digits that can represent the Identifiers. In other words, there is a total of 63 alphanumeric characters that can be used to make the Identifiers.
Uppercase: A B C ................................... X Y Z Lowercase: a b c ..................................... x y z
C accepts both lowercase and uppercase alphabets as Identifier names.
0 1 2 3 4 5 6 7 8 9
|Special Characters in C Language|
Rules for naming C Identifiers
- A valid Identifiers can be composed using both uppercase, lowercase alphabets, underscore, and digits.
- The first characters of the Identifiers should be either an alphabet or underscore.
- It should begin with any digits.
- You can not use keywords such as
- Commas and blank can not be used in the Identifiers.
- There is no rule on how long the Identifiers should be. However, you may get errors in some compilers if the length of the Identifiers is more than 31 characters.
- The name of the Identifiers should be written in such a way that is meaningful, short, and easy to read.
Example of valid Identifiers
count, name, _flag, _b_, new_1, etc.
Example of invalid Identifiers
3count (starts with a numerical digit) int (reserved word) char (reserved word) m-n (special character, i.e., '-')
Difference between Keyword and Identifier
|Keyword is a predefined word.||Identifier is a user-defined word.|
|Keyword must be written in lowercase.||It can be in both uppercase or lowercase.|
|Meaning of keywords is predefined in the C compiler.||Its meaning is not defined in the C compiler.|
|It is a combination of alphabetical characters only.||It is a combination of alphanumeric characters.|
|It does not contain the underscore character.||It can contain the underscore character.|