C language variable name rules are: 1. The variable name starts with an English letter; 2. The letters in the variable name are case-sensitive; 3. The variable name cannot be a keyword; 4. The variable name cannot Contains spaces, punctuation, and type specifiers.
Recommended: "c Tutorial"
When defining a variable, the variable name can be letters, A combination of numbers and underscores. But it is not a random combination. Please pay attention to the following naming rules:
1. The variable name starts with an English letter;
The variable name cannot start with a number. Can start with a letter or an underscore. However, in fact, the most commonly used names in programming begin with a letter, and variable names beginning with an underscore are system-specific.
Open any header file and you will see that all variable names, macro names, and function names in it all start with an underscore.
So in order to avoid conflicts with system-defined names, when programming, never use an underscore as the beginning of a variable name unless it is required to be defined in this way.
Correct variable name:
int In_1=2; int abc=5;
Incorrect variable name:
int 1In_1=2; int 2abc=5;
2. It cannot contain spaces, punctuation marks and type specifiers (%, & ,!, #, @, $);
//错误的变量名:不能包含空格、标点符号和类型说明符(%、&、!、#、@、$),只能是字母、数字、下划线组成。 int %age = 13; int a%ge = 13; int name age = 12;
3. Letters are case-sensitive;
//变量n和变量N是两个变量。 int n = 11; int N = 18;
4. The effective length is 255 characters;
5. It cannot be a keyword;
//错误的变量名:case是C语言的一个关键字,不能作为变量名 int case = 12;
The keywords defined in C language are:
There are 32 C language keywords defined by the ANSI standard: auto, double, int, struct, break, else, long, switch, case, enum, register, typedef, char, extern, return, union, const , float, short, unsigned, continue, for, signed, void, default, goto, sizeof, volatile, do, if, while, static.
These 32 keywords have been used by the C language itself and cannot be used for other purposes. For example, they cannot be defined as variable names or function names.
The above is the entire content of this article, I hope it will be helpful to everyone's study. For more exciting content, you can pay attention to the relevant tutorial columns of the PHP Chinese website! ! !
The above is the detailed content of What are the rules for variable names in C language?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Zend Studio 13.0.1
Powerful PHP integrated development environment

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver CS6
Visual web development tools