in Technology by

What is a static variable in C-Programming?

Please log in or register to answer this question.

1 Answer

0 votes
by

A static local variables retains its value between the function call and the default value is 0. The following function will print 1 2 3 if called thrice.

void f() { 

   static int i; 

   ++i; 

   printf(“%d “,i); 

}

If a global variable is static then its visibility is limited to the same source code.

Related questions

+1 vote
asked Nov 9, 2020 in Technology by JackTerrance
0 votes
asked Mar 30, 2022 in Education by JackTerrance
0 votes
asked Feb 27, 2022 in Education by JackTerrance
...