A quick test shows that a and c are 0.
int a; static int c; int main() { printf("%d %d\n", a, c); return 0; }
The location (and c) is determined at compile time; that is, they are not pushed onto the stack or into the memory interval returned by malloc. I think the C standard says that in all cases they are initialized to 0.
I am 99.9% sure about c and 98% sure about a . The static , in the context of global variables, is really similar to private in (say) C ++ and Java: it's about visibility, not about the location of the repository.
What Andrew Hare says about uninitialized variables is true for data stored on the stack or in malloc'd memory. Not so for statically stored variables.
source share