Difference Between Keywords and Identifiers
Having discussed the meaning of each token type which is a keyword and an identifier, now we shall see the difference between keywords and identifiers. The differences are as follows:
Key Differences Between Keywords and Identifiers
It should always be in lower case.
It can be in lower case or upper case.
It has a predefined meaning. They are reserved for use by the user.
It has no meaning attached to it. Usually, an identifier is a name provided by the user.
It can contain only the alphabet.
They can contain alphabets, digits, and underscores.
No special symbol is used.
Except for the underscore, no other special symbol is used.
It specifies the type of entity.
It gives a name to the type of entity.
Example: void, int, signed, etc.
Example: test, _abc, etc.
What is a Keyword in C?
Keywords are predefined reserved words present to the user in the C language. Any C program must have keywords present in it. In fact, a program in C begins with the keyword itself. The keyword is a type of C token.
In C, there are 32 reserved words or keywords present. Keywords are used in functions, blocks, loops, user-defined data structures, etc. The keywords are as follows: auto, default, float, register, struct, volatile, break, do, for, return, switch, while, char, else, if, signed, union, case, double, goto, short, typedef, const, enum, int, sizeof, unsigned, continue, extern, long, static, void.
What is an Identifier in C?
An identifier is just a name given to memory space or to a function for future reference in the program. An identifier does not have predefined meanings. They are user-defined names composed of letters and digits.
For an identifier to be valid, we need to follow the predefined rules to declare an identifier that is an identifier should only begin with a letter or an underscore and not by any digit. It cannot consist of any other special symbol other than letter, digits, and underscore.
Check out the following topics related to the difference between keywords and identifiers: