What is meant by global static? why we have to use static
variable instead of Global variable
Answer Posted / indira amit
Variables defined local to a function disappear at the end
of the function scope. So when we call the function again,
storage for variables is created and
values are reinitialized. So if we want the value to be
extent throughout the life of a program, we can define the
local variable as "static." Initialization is performed only
at the first call and data is retained between func calls.
Had it been gloal variable, it would have been available
outside the scope of the function, but static variable is
not available outside the scope of a function (helpful in
localizing errors - as it can't be changed outside the func
scope).
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How do I create a directory? How do I remove a directory (and its contents)?
What is a program flowchart and how does it help in writing a program?
What is the difference between pure virtual function and virtual function?
Should a function contain a return statement if it does not return a value?
When do we get logical errors?
What is string concatenation in c?
Why ca not I do something like this?
Explain enumerated types.
Describe the difference between = and == symbols in c programming?
What is maximum size of array in c?
How can I invoke another program or command and trap its output?
Is a house a mass structure?
What is the right type to use for boolean values in c? Is there a standard type?
Why doesnt this code work?
What does node * mean?