Identifiers are used for any variables, functions, data definitions, labels, etc. in the program.
Before starting any language, you must at least know how to name identifiers.
In C language, an identifier is a combination of alphanumeric characters, that is, it starts with a letter or an underscore, and the rest is a letter, any number, or an underscore. Identifier naming rulesThe rules that must be followed when naming identifiers are as follows -
The case of alphabetic characters is important. For example, using "TUTORIAL" for a variable is different from using "tutorial" for a variable, and it is different from using "TutoRial" for a variable. These three variables all refer to different variables.
There is no requirement for the length of identifiers. We may run into problems with some compilers if the identifier is longer than 31 characters. The situation is different for different compilers.
Valid identifiers can contain letters (uppercase and lowercase), numbers, and underscores.
The first letter of the identifier should be a letter or an underscore.
You cannot use keywords such as int and while as identifiers.
Identifiers must be unique
For example,
int student; float marks;
Here, student and marks are identifiers.
We must remember that identifier names must be different from keywords. We cannot use int as identifier because int is a keyword.
Consider another identifier example.
int var1, var2; float Avg; function sum();
keywords are used with identifiers to define them. Keywords explain to the compiler the function of an identifier.
The above is the detailed content of In C language, what is an identifier?. For more information, please follow other related articles on the PHP Chinese website!