Dan Jue wrote:
> > > int main ()
> > > { const dim = 5;
> > > float a[dim-1][dim-1];
> >
> > The above creates a matrix of [4][4]; that is, each dimension varies from
> > [0] to [3]. a[0][3] is the last element of the first row; a[0][4] is
> > infact the first element of the second row which is better represented by
> > a[1][0].
>
> Are we allowed to assume that row-major order arrays are totally
> contiguous in memory for any platform (by your example of address
> a[0][4])?
Yes.
> For arrays of structures or objects (or some other big unit),
> is it not possible for their locations in memory to be non-contiguous?
No.
> Also i'm assuming that you cannot access a[0][4] directly because wouldn't
> that cause an out-of-bound subscript error?
No. There is no subscript checking in C. a[0][4] means exactly the
same thing as *(a[0] + 4).
> So you would instead do some manual pointer arithmetic to get that
> address, right?
Array accesses are just a convenient syntax for pointer arithmetic.
--
Glynn Clements <[EMAIL PROTECTED]>