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


Please Help Members By Posting Answers For Below Questions

What is c++ used for today?

664


Why C language is a procedural language?

617


What is volatile c?

522


What does it mean when a pointer is used in an if statement?

600


Explain 'bit masking'?

650






Why doesnt long int work?

611


What is the heap in c?

639


Why does everyone say not to use gets?

605


Explain the use of #pragma exit?

696


Write a program to check palindrome number in c programming?

596


What are unions in c?

578


Can a file other than a .h file be included with #include?

684


what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;

2006


What is New modifiers?

667


There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?

821