What is meant by global static? why we have to use static
variable instead of Global variable

Answers were Sorted based on User's Feedback



What is meant by global static? why we have to use static variable instead of Global variable..

Answer / guest

Static is protected one and you cannot acess the variable
in other files/functions.It is declared in the top of the
file/function.The value retains tho,t the program.

Is This Answer Correct ?    6 Yes 0 No

What is meant by global static? why we have to use static variable instead of Global variable..

Answer / vaibhav

global static means the static value declared as a
global.using this we can share same copy of that variable.

Is This Answer Correct ?    1 Yes 1 No

What is meant by global static? why we have to use static variable instead of Global variable..

Answer / 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

What is meant by global static? why we have to use static variable instead of Global variable..

Answer / abdur rab

Static remains throughout the program, however its scope is
limited to that file alone. If a program consists of
multiple files, you want a variable to be seen by the
entire file and do not want that variable to be seen by the
other files, then mark is as static

static int a;

as a global variable

Is This Answer Correct ?    2 Yes 3 No

Post New Answer

More C Interview Questions

Is c procedural or object oriented?

0 Answers  


Can we access RAM? How? Whats the range of access? Similarly What are other hardware we can access?

1 Answers  


Difference between fopen() and open()?

3 Answers   Aricent,


Why c is called a mid level programming language?

0 Answers  


Explain the advantages of using macro in c language?

0 Answers  






What are 3 types of structures?

0 Answers  


Tell me a C program to display the following Output? 1 1 1 1 1 2 2 2 2 3 3 3 4 4 5

3 Answers  


Explain what are the __date__ and __time__ preprocessor commands?

0 Answers  


how can we use static and extern?and where can we use this?

3 Answers   Excel,


I use turbo C which allocates 2 bytes for integers and 4 bytes for long. I tried to declare array of size 500000 of long type using the following code... long *arr; arr=(long *)(malloc)(500000 * sizeof(long)); It gives a warning that "Conversion may lose significant digits in function main"... And the resulting array size was very less around 8400 as compared to 500000. Any suggestions will be welcomed....

2 Answers  


Describe how arrays can be passed to a user defined function

0 Answers  


Is c is a procedural language?

0 Answers  


Categories