C variables

1, the variable attribute: data type and storage type

2, the storage type of a variable determines the type of variable storage area allocated, and the type of the variable storage area in turn determines the scope and lifetime of variables

3, four kinds of languages stored in a variable of type C: automatic type (Auto), external (extern), a static type (static), type register (register)

4, external variables:

Definitions Before all functions, with all the functions of the program can be used directly, without reference; if middle-defined or used in other documents in, you need to reference: (not required when allocating memory references) extern variable name

If the function of external variables and internal variables of the same name, is used inside the variable name, the default variable outer shield

5, automatic static local variables and variables similarities and differences:

With: the scope where the function is

Different: After the function call, the value of the automatic variable is released, and the value of a static local variable will be retained

6, static global variables and global variables similarities and differences

The same: both static storage

Different: Scope static global variables as the source file is located, which can only be used by a function of the source program, scope and global variables can be extended to other source by keyword extern

 

 

Guess you like

Origin www.cnblogs.com/pam-sh/p/12431752.html