Home  >  Article  >  Backend Development  >  In C language, what is an identifier?

In C language, what is an identifier?

WBOY
WBOYforward
2023-09-02 22:09:102980browse

In C language, what is an identifier?

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 rules

The 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();

Here,

  • int, float, and function are all keywords.
  • var1, var2, Sum, Avg are identifiers.
  • var1, var2, Sum, Avg are identifiers. li>

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete