Ques : What is Static Variables

, , No Comments

In case of single file programs static variables are defined within functions and individually have the same scope as automatic variables. But static variables retain their values throughout the execution of program within their previous values. Points to remember:

• The specifier precedes the declaration. Static and the value cannot be accessed
outside of their defining function.
• The static variables may have same name as that of external variables but the
local variables take precedence in the function. Therefore external variables
maintain their independence with locally defined auto and static variables.
• Initial value is expressed as the constant and not expression.
• Zeros are assigned to all variables whose declarations do not include explicit
initial values. Hence they always have assigned values.
• Initialization is done only is the first execution.

0 टिप्पणियाँ:

Post a Comment