1,arrays is automatic counting,
A second shorthand for arrays is automatic counting, in which you
let the compiler determine the size of the array based on thenumber of initializers:
int c[] = { 1, 2, 3, 4 };
Now if you decide to add another element to the array, you simply
add another initializer. If you can set your code up so it needs to be
changed in only one spot, you reduce the chance of errors during
modification. But how do you determine the size of the array? The
expression sizeof c / sizeof *c (size of the entire array divided by
the size of the first element) does the trick in a way that doesn’t
need to be changed if the array size changes5
:
for(int i = 0; i < sizeof c / sizeof *c; i++)
c[i]++;
2,do{} while(0);