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

a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above

976


What language is c written?

743


How many types of arrays are there in c?

770


Why is this loop always executing once?

788


Array is an lvalue or not?

837


What is difference between array and structure in c?

776


Why are algorithms important in c program?

813


what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?

1647


Explain the use of 'auto' keyword

870


What are derived data types in c?

790


What is c standard library?

885


What is a MAC Address?

807


ATM machine and railway reservation class/object diagram

4986


What is the purpose of sprintf?

814


Explain Basic concepts of C language?

815