1
What is a static variable in C-Programming?

Open 1 Answers 36 Views Technology
What is a static variable in C-Programming?

1 Answer

0

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.

by (249k points)
...