Detailed Explanation of C Language Identifiers

C identifiers are used to represent names in C programs, such as variables, functions, arrays, structures, unions, labels, etc. Identifiers can consist of uppercase letters, lowercase letters, underscores, and digits, but the first character must be a letter or an underscore. If an identifier is not used in external linkage, it is called an internal identifier. If an identifier is used in external linkage, it is called an external identifier.
We can say that an identifier is a collection of characters that starts with a letter or an underscore and includes letters, digits, and underscores, used to represent various programming elements such as variables, functions, arrays, structures, unions, labels, etc. There are 52 letter characters (both uppercase and lowercase), an underscore character, and ten digit characters (0-9) available. In total, there are 63 alphanumeric characters that can be used to represent identifiers.

Rules for Constructing C Identifiers

  • The first character of the identifier should be a letter or an underscore, followed by any combination of characters, digits, or underscores.
  • Identifiers cannot start with a digit.
  • Identifiers are case-sensitive, so we can say that identifiers are case-sensitive.
  • Identifiers cannot contain commas or spaces.
  • Keywords cannot be used as identifiers.
  • The length of an identifier should not exceed 31 characters.
  • Identifiers should be written in a meaningful, concise, and easy-to-read manner.
Examples of Valid Identifiers
total, sum, average, m, sum_1, etc.
Examples of Invalid Identifiers
2sum (starts with a numerical digit)  int (reserved word)  char (reserved word)  m+n (special character, i.e., '+')

Types of Identifiers

  • Internal Identifier
  • External Identifier

πŸ‘‡ Click to ClaimπŸ‘‡

πŸ‘‰ Collection of C Language Knowledge Materials
Internal Identifier
If an identifier is not used in external linkage, it is called an internal identifier. Internal identifiers can be local variables.
External Identifier
If an identifier is used in external linkage, it is called an external identifier. External identifiers can be function names or global variables.

The Difference Between Keywords and Identifiers is as Follows

Detailed Explanation of C Language Identifiers

Let’s Understand Through an Example
int main()  {     int a=10;     int A=20;     printf("The value of a is: %d",a);     printf("\nThe value of A is: %d",A);     return 0;  }
Output
The value of a is: 10The value of A is: 20

The above output shows that the values of variable ‘a’ and ‘A’ are different. Therefore, we can conclude that identifiers are case-sensitive.

Programmer Technical Exchange Group

Please remember to note: City, Nickname, and Technical Direction when scanning to join the group.



Leave a Comment