c language static notes

%% time will give a time code running cell once it takes.

In simple terms
before the local variables plus static can prolong his life cycle
extended to the survival of the program when called by the function of the period

Before adding static global variable can reduce its scope
can be seen from multiple files, a single file can be seen to be reduced

Before explaining the bureau coupled with static variables constitute a static global variable. Global variables itself is static storage mode, static global variables of course, a static storage. This is no different in the two storage methods. Although this difference is non-static global variable scope is the whole source, when a source program by a plurality of source files, non-static global variable in each source file is valid. A static global variables are restricted in its scope, that is only valid within the definition of the variable in the source file, it can not use the same files in the other sources in the source program. Due to the limited scope static global variables within a source file, can only function in the source file for the public, so to avoid causing errors in the other source files. From the above analysis, the local variables as static variables after the change is to change its storage that is changing its survival. After changing global variables as static variables are changed its scope, limiting its scope.

Published 73 original articles · won praise 2 · Views 4371

Guess you like

Origin blog.csdn.net/qq_43373608/article/details/104329465