When a process's global variable is declared as static, its Chinese name is called a static global variable. There is no difference between a static global variable and a storage location for other global variables, but it is only valid within the source file that defines it, and other source files cannot access it.
The static local variable is called a statically local variable. It differs from ordinary local variables in the following different aspects:
1) Location: The static local variable is placed in the global store by the compiler, so it is local, but exists throughout the lifetime of the program.
2) Access rights: Static local variables can only be accessed by variables or functions within their scope. This means that although it will exist throughout the life of the program, because it is static, it cannot be accessed by other functions and source files.
3) Value: If the static local variable is not initialized by the user, it is automatically assigned a value of 0 by the compiler, and the last call value is used each time the static local variable is called.
Copyright NOTICE: This article is the original blogger articles, reproduced please indicate the source.
The static variable in C