Possible Duplicate:
The initialization of static variable in C
I know that either global variables or static are automatically initialized with zero in C. However, I'm not sure if both or only one of them are initialized. Note that I'm not talking about variables defined in functions but globally in the .c file.
So which of the following variables are automatically initialized with zero?
static struct mystruct var1;
struct mystruct var2;
static struct { int x; int y; } var3;
C FAQ.
I ran the following code in codepad
results:
Regardless, I don't like making assumptions about initialisation but YMMV.