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
Why is c fast?
Is exit(status) truly equivalent to returning the same status from main?
A float occupies 4 bytes in memory. How many bits are used to store exponent part? since we can have up to 38 number for exponent so 2 ki power 6 6, 6 bits will be used. If 6 bits are used why do not we have up to 64 numbers in exponent?
the question is that what you have been doing all these periods (one year gap)
What are the different types of data structures in c?
What are the 5 organizational structures?
What does printf does?
What are different types of variables in c?
Explain can static variables be declared in a header file?
What are preprocessor directives in c?
What is the process to generate random numbers in c programming language?
Is there anything like an ifdef for typedefs?
What is && in c programming?
How can I ensure that integer arithmetic doesnt overflow?
What is the function of volatile in c language?