I'm reading C How to Program and I have a question about storage classes of arrays. In the book it says:
Array and structs are "static" entities in that they remain the same size throughout the program execution (they may, of course, be of automatic storage class and hence created and destroyed each time the blocks in which they're defined are entered and exited)
I'm not sure about what blocks mean, my current understanding is that function/for/while are blocks. I've tried the following:
...
for (size_t i=1; i<=2; i++) {
printf("round %c:", i+'0');
int a[10];
show_array(a, 10); // this is a function that prints all elements of `a`.
for (size_t j=0;j<10;j++) {
a[j]=8;
}
}
I got the output:
round 1:0,0,0,0,-1160480784,22023,-1160481168,22023,1594487680,32766,
round 2:8,8,8,8,8,8,8,8,8,8,
It seems like int a[10] is static, and not automatic storage class, am I missing something? (I understand the four storage classes)
I used ideone.com to run my test, if you need this information.
32766or-1160481168"unitialised values"? If they are, why8isn't?{and}, with declarations and/or statements inside it.