Node:Static variables, Next:, Previous:External variables, Up:Storage classes



Static variables

A second important storage class specifier is static. Normally, when you call a function, all its local variables are reinitialized each time the function is called. This means that their values change between function calls. Static variables, however, maintain their value between function calls.

Every global variable is defined as static automatically. (Roughly speaking, functions anywhere in a program can refer to a global variable; in contrast, a function can only refer to a local variable that is "nearby", where "nearby" is defined in a specific manner. See Scope, for more information on global variables. See Expressions and operators, for an example of a static local variable.)