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
What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.
What is extern keyword in c?
How can I read data from data files with particular formats?
What are the data types present in c?
What is the purpose of macro in C language?
What is data type long in c?
Explain the difference between malloc() and calloc() function?
What is c mainly used for?
What is volatile keyword in c?
Why c language is called c?
Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)
write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.
Where is volatile variable stored?
What is string constants?
What is an expression?