Even after looking at a lot of books, I am not able to understand the problem in the following code:
//1.c
static int y=23;
void abc(int a){
printf("%d\n",a);
}
//2.c
#include<stdio.h>
#include "1.c"
int main(){
abc(12);
printf("\n");
printf("%d\n",y);
return 0;
}
I can understand that the functions abc is accessible to this file, but how is this variable y accessible here?
The static declaration, applied to an external variable or function, limits the scope of that object to the rest of the source file being compiled.
from: dennis ritchie
So, how is this static variable in 1.c printed here?? :-/