PDF

Identifiers

Leave a Comment
In 'C' Language any name is called 'identifier'. This name can be variable name, function name, enum constant name, micro constant name, goto label name, any other data type name like structure, union, enum names or typeof name.

Rule 1: Name of identifier includes alphabets, digit and underscore.

Valid name: world,addition21, sum_of_number etc.
Invalid name: factorial#, avg value, display*number etc.

Rule 2: First character of any identifier must be either alphabets or underscore.

Valid name: _calculate, _5, a_, _ etc.
Invalid name: 5_, 10 =_function, 123 etc.

Rule 3: Name of identifier cannot be any keyword of C program.

Invalid name: float, enum etc.

Rule 4: Name of identifier cannot be exactly same as of name of function within the scope of the function.


Example:

#include<stdio.h>
int main()
{
int printf = 5;   // don't do this
printf("%d",printf);
return 0;
}

Output: Compilation error


Rule 5: Name of identifier is case sensitive i.e. num and Num are two dirrent variables.


Rule 6: Only first 32 characters are significant of identifier name.


Example: 
abcdefghijklmnopqrstuvwxyz123456aba
abcdefghijklmnopqrstuvwxyz123456bcb
abcdefghijklmnopqrstuvwxyz123456czc

All above three identifier names are same because only first 32 characters has meaning. Rest has not any importance.

Rule 7: No two successive underscores are allowed.


Rule 8: identifier name cannot be exactly same as constant name which have been declared in header file of c and you have included that header files.



0 comments:

Post a Comment