Static can be used to modify variables or functions in c.
1. static local variables
A. lifecycle: static local variables are defined in the function, and the lifetime is the entire source program;
B. Storage Method: When static modification is used, the storage from the original stack is changed to static storage zone;
C. Scope: it is the same as an automatic variable and can only be used in the function defining the variable. After exiting the function, although the variable still exists, it cannot be used;
D. initialization: if an initial value is not assigned to a static local variable of the basic type, the system automatically assigns a value of 0. If an initial value is not assigned to an automatic variable, the value is not fixed.
2. static global variables
A. Storage Method: global variables are static storage methods, and static global variables are also static storage methods;
B. scope: the scope of a non-static global variable is that multiple source files of the entire source program can be used together), while a static global variable limits its scope, that is, it is valid only within the source file that defines the variable.
3. static Functions
It can only be called by functions in this file, but not by functions in other files of the same program. Different from external functions of non-static functions ).
This article is from the "Sun's technology blog" blog, please be sure to keep this source http://sunke.blog.51cto.com/4812218/1282566