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

In C language, what is an identifier?

WBOY
Release: 2023-09-02 22:09:10
forward
3011 people have browsed it

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;
Copy after login

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();
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template