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
Can you assign a different address to an array tag?
What is the data segment that is followed by c?
What are the benefits of organizational structure?
Why do we use stdio h and conio h?
What is the symbol indicated the c-preprocessor?
Why do we write return 0 in c?
What is the use of a ‘ ’ character?
Is malloc memset faster than calloc?
Can an array be an Ivalue?
What is the purpose of scanf() and printf() functions?
differentiate built-in functions and user – defined functions.
write an algorithm to display a square matrix.
What are compound statements?
Where define directive used?
In C, What is the #line used for?