In any programming language developer must to know how to name an identifier. An identifier (in programming language) is a combination of alphanumeric characters, the first being a letter of the alphabet or an underline, and the remaining being any letter of the alphabet, any numeric digit, or the underline. In other words, its present the names that are given to various program elements such as variables, symbolic constants, functions and data definition, etc.

To be declares identifiers programmers must to keep the following point in his mind:

  • Alphanumeric characters (a ~ z , A~Z , 0~9) and half underscore ( _ ) can only be used.
  • The first character of the first contain letters (a ~ z, A~Z) or half underscore (_) can only be used.
  • Language is Case sensitive or distinguishable. It means that compiler of the language recognized ‘word’ and ‘WORD’ as a separate identifier.
  • Reserved words or special characters are not allowed to declare as identifiers. However, part of an identifier reserved words can be included.

Note: In case of some compilers, a dollar sign ($) is permitted in the identifier name but not as the first character of an identifier. It should be pointed out that even though a dollar sign may be permitted by your C compiler, it is not used anywhere in this tutorial since it is not in general use by C programmers, and is not even allowed by most compilers. If you do not plan to write any portable code, you can use it at will if you feel it makes your code more readable.

List of Rules and restriction by programming language C that are needed to know before mention an identifier:

  • Identifier name must be a sequence of letter and digits, and must begin with a letter.
  • The underscore character (‘_’) is considered as letter.
  • Names shouldn’t be a keyword (such as int, float, if, break, for etc.)
  • Both upper-case letter and lowercase letter characters are allowed. However, they’re not interchangeable.
  • No identifier may be keyword.
  • No special characters, such as semicolon, period, blank space, slash or comma are permitted.
  • Programming language C is defined; up to 32 significant characters can be used and will be considered significant by most compilers. Due to that if more than 32 are used, they will be ignored by the compiler.

Examples: Legal identifiers

  • float a;
  • int this_is_a_very_detailed_name_for_an_identifier;

Examples: Illegal identifiers:

  • float :e;
  • float for;
  • float 9PI;
  • float .3.14;
  • float 7g;

You got about what is Identifiers in C programming language and the detail information about rules and restrictions about the name identification of the Identifiers in programming languages.



Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.