
Originally Posted by
Salem
Code:
int a;
static int b;
void foo ( ) {
static int c;
}
.
Thank you salem
modified version
Code:
int a; //Global variable
static int b; // Static Global variable
void foo ( ) {
static int c; //Static local variable
}
int main (){
foo();
return 0;
}
All have a lifetime the same as the program.
All are default initialised to 0, unless you provide some other initialiser.
Then
a is visible to the entire program.
b is visible to all the functions in the current source file that appear after the definition of b.
c is visible only to the function in which it is defined