The storage type of variables is an important part of C language and the basis of C language learning. What kinds of variables are stored in the C language? How to use it in the programming process? On this issue, I would like to introduce to you today! In general, there are four types of variables stored in C, namely, Automatic, Static, external, and register variables, with the following specifiers: auto, static, extern, and register.
First, Auto
Auto is called an automatic variable.
A local variable is a variable (sometimes also called an automatic variable) that is described inside a function. With the keyword auto, when auto omits, all non-full variables are considered local variables, so auto is never actually used.
For example:
{int i,j,k;
char c;
......
} equivalent to: {auto int i,j,k;
Auto Char c;
......
}
Second, static
Static variables are called statics. Depending on the type of the variable can be divided into static local variables and static whole variables.
1. Static local Variables
It differs from a local variable in that the variable is always present when the function exits, but cannot be used by other functions, and the last result is saved when the function is entered again. Others are the same as local variables.
2. Static whole variable
Turboc the large program into separate module files compiled separately, then the target files of all the modules are connected together, so as to improve the speed of compilation, but also facilitate the management and maintenance of software. A static whole variable is a variable that is visible only in the source file in which it is defined and not in other source files. The difference between it and the whole variable is that the whole variable can be further described as an external variable (extern), used by other source files, and static whole variables can no longer be described as external, that is, can only be used by the source file.
Third, extern
extern is called an external variable. In order for the variable to be used in addition to the source file in which it is defined, it is also used by other files. Therefore, the full variable must be notified to each program module file, which can be described by extern.
Iv. Register
Register is called a register variable.
This article belongs to the world http://www.huiyingtianxia.net/all, reproduced please indicate the source!
What are the types of variables stored in C language?