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
Where local variables are stored in c?
What is #include stdio h?
Is c# a good language?
What does do in c?
Can we access the array using a pointer in c language?
What is the importance of c in your views?
What is malloc calloc and realloc in c?
I was asked to write a program in c which when executed displays how many no.of clients are connected to the server.
Where in memory are my variables stored?
Create a structure to specify data on students as given below: Roll number, Name, Department, Course, and Year of joining. Assume that there are not more than 450 students in the collage. (a) Write a function to print the names of all students who joined in the last 3 years. (b) Write a function to print the data of a student whose roll numbers are divisible by 4.
What is a nested formula?
Explain what are the standard predefined macros?
how to count no of words,characters,lines in a paragraph.
What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?
What is c variable?