C Identifiers

The Identifiers in C are the names of things such as functions and variables.

  • A C identifier is made up of letters, numerals and underscore. letters from A to Z (both uppercase and lowercase), numerals from 0 to 9 and underscore _.
  • An identifier may start with underscore or letter, but cannot start with numeral.
  • As C is case sensitive language. The uppercase and lowercase letters are treated as different letters. So the compiler will treat MyVar as a different identifier from myvar.
  • You cannot use keywords as identifiers. However, keyword can be part of an identifier name. For example, an identifier with name int is not allowed as int is keyword, but myint is allowed.
  • The ANSI allows 6 significant characters in an external identifier’s name and 31 characters for internal identifiers.
  • Identifiers should be meaningful and easy to read. For example, an identifier firstName for ‘First Name’ would be a better choice as compared to x1.

Example of legal identifiers in C

age, exponent, Temp, WORLD, myint

Example of illegal identifiers in C

  • 2avg (starts with numeral)
  • int (keyword)
  • %dollar (contains illegal letter %)
  • Tom’s (contains illegal letter ‘)