On Mar 25, 6:00 pm, Keith Thompson <ks...@[EMAIL PROTECTED]
> wrote:
> no...@[EMAIL PROTECTED]
writes:
> > #include <stdio.h>
>
> > char uu[5][4];
>
> > main()
> > {
> > printf("%p %p %p\n",&uu[0][0],&uu[1][0],&uu[0][1]);
> > }
>
> > gives
>
> > C:\a>kwik
> > 0040C1F0 0040C1F4 0040C1F1
>
> > This suggests the rightmost array subscript iterates most quickly, so
> > uu is an array of 5 of array of 4 of char.
>
> > Is that understanding correct? Sorry for such a trivial question but I
> > think my understanding hitherto has been wrong.
>
> Yes, your understanding is correct. And, as it turns out, this
> wasn't an arbitrary choice; C couldn't have defined it the other
> way without some major changes. (<OT>Note that Fortran's rules
> are different.</OT>)
>
> The key point to understand here is that C doesn't really have
> multidimensional arrays as a distinct feature. Your declaration
>
> char uu[5][4];
>
> simply declares an array of arrays. The behavior, including the
> fact that the rightmost subscript iterates most quickly, follows
> from that.
>
> Note that the standard does talk about multi-dimensional arrays.
> Strictly speaking, this is redundant; eveything the standard says
> about multi-dimensional arrays follows directly from the rules for
> one-dimensional arrays. But in this case the redundancy is probably
> a good thing; C's array rules are subtle enough that extending them
> to the multi-dimensional case is not trivial.
>
> For more information, see section 6 (Arrays and pointers) of the
> comp.lang.c FAQ, <http://www.c-faq.com/>.
Hm.. now I'm confused too. is T arr[4][5] an array of 4 arrays of 5
Ts? or an array of 5 arrays of 4 Ts?
I believe it's the latter. (so, arr[0] is an array of 4 Ts)
Moreover, in the FAQ in question 6.17 there is an additional link
labeled "Yes, Virginia", but the link leads to a page with no content.
(it is not an external link)
Any idea what that is?
>
> Finally, some minor quibbles about your code, unrelated to your
> question:
<snip>


|