4.
char abc[120][80];
Rewrite it with all parentheses explicitly shown:
char ((abc[120])[80]);
and read it from the inside out:
- abc is being declared,
- it is an array of 120 things,
- each of them is an array of 80 other things,
- they are characters.
So abc is a two dimensional (120x80) array of characters.
or
abc is an array of 120 80-character strings.
but
abc can not be treated as an array of 80 120-character strings.
Important Note
This is not the
same thing as:
char *abc[120];
In a way, they are both arrays of 120 strings, but the version we are
looking at really allocates all the memory for all the strings; they are
fixed at 80 characters each. The other version (with the *) is
really just an array of pointers to strings. The strings themselves do
not exist yet; the programmer will have to make the pointers point to
something useful before they can be used.
(sizeof abc) is 9600 (that is 120*80).
(sizeof abc[2]) is 80.
(sizeof abc[2][71]) is 1.