ADVERTISEMENT
Keywords and Identifiers In C
Identifiers
A C identifier is a name that is used to find a variable, function, or anything else that was created by the user. It starts with a letter (A to Z, a to z) or an underscore (_), and then it has zero or more letters, underscores, or digits (0 to 9).
It is not possible to use punctuation like @, $, and % in identifiers in C. When you write code in C, the case of the words matters. This means that Manpower and manpowerare not the same thing in C.
These are some examples of good identifiers:
amount | salary | abc | Move_name | abc_123 |
name10 | _temporary | i | x12z34 | returnVal |
Keywords
The words that can’t be used in C are shown below. There are some words that can’t be used as constants, variables, or any other kind of identifier names.
These are some Reserve Keyword:
auto | else | long | switch |
break | enum | register | typedef |
case | extern | return | union |
char | float | short | unsigned |
const | for | signed | void |
continue | goto | sizeof | volatile |
default | if | static | while |
do | int | struct | _Packed |
double |
Whitespace In C
A line withonly whitespace, maybe a comment, is called a blank line, and a C compiler doesn’t care about it at all.
int age;C ProgrammingThe compiler can tell the difference between int and age if there is at least one whitespace character between them. This is usually a space. In the following sentence, on the other hand.
fruit = apples + oranges; // get the total fruitC ProgrammingThere is no need for whitespace between fruit and = or between = and apples, but you can add some if you want to make the text easier to read.
Rules for naming identifiers
- A valid identifier can have letters (both uppercase and lowercase letters), digits and underscores.
- The first letter of an identifier should be either a letter or an underscore.
- You cannot use keywords like
int,whileetc. as identifiers. - There is no rule on how long an identifier can be. However, you may run into problems in some compilers if the identifier is longer than 31 characters.