static modified variable

static modified local variables and global variables

1.static modification of local variables:

Changed the lifetime of the variable ( whole project )

but doesn't change the scope of the variable ( still local scope )

2.static modification of global variables

Changed the scope of the variable; ( cannot be referenced for external source files, ie: cannot be imported with extern )

Does not change the lifetime of the variable ( still the whole project )

The following code is used as an example




A screenshot of the external source file (with the variable g_val defined) is as follows



The result is as follows



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324838724&siteId=291194637