C language knowledge - concept of definition, declaration, initialization, assignment

Definition: determine the location and size of the variable in memory, that is, allocate space for the variable at the time of definition

Declaration: Indicates the type and name of the variable to the program

Initialization: the value assigned to a variable when it is defined

Assignment: Assign a new value to a variable

int i;   //定义性声明,即使定义也是声明
int i=9;  //初始化
extern int i;   //引用性声明
i=7;    //赋值

The difference between variable declaration and definition:

        There are two cases of declaration: the same variable can be declared in multiple places

                1) Definitive statement: a statement to create a storage space, which is both a statement and a definition

                2) Referential declaration: declare external variables

         Definition: The same variable can only be defined once

Guess you like

Origin blog.csdn.net/Healer19/article/details/119117165