Identifier in C

By | August 16, 2020

A token is the smallest element of a program that is meaningful to the compiler. Tokens can be classified as follows:

  • Keywords
  • Identifiers
  • Constants
  • Strings
  • Special Symbols
  • Operators

Identifiers


Identifiers are names for entities in a C program, such as variables, arrays, functions, structures, unions and labels.

An identifier can be composed only of uppercase, lowercase letters, underscore and digits, but should start only with an alphabet or an underscore. Identifiers are also case sensitive in C.

Rules for Identifiers :

  1. The first character in an identifier must be an alphabet or an underscore and can be followed only by any number alphabets, or digits or underscores.
  2. They must not begin with a digit.
  3. Uppercase and lowercase letters are distinct. That is, identifiers are case sensitive.
  4. Commas or blank spaces are not allowed within an identifier.
  5. Keywords cannot be used as an identifier.
  6. Identifiers should not be of length more than 31 characters.
  7. Identifiers must be meaningful, short, quickly and easily typed and easily read.

Type of identifiers :
There are two types of identifiers in C: Internal, and External. Local variable and global variable are the examples of internal and external identifier respectively. Internal identifier has at least 31 significant characters and External identifier has at least 63 significant characters.



Please write comments if you find anything incorrect. A gentle request to share this topic on your social media profile.