[comp.std.c] Holes in 2-D array?

walter@hpclwjm.HP.COM (Walter Murray) (02/07/89)

Can a multi-dimensional array have holes?

Think of a machine with 8-bit bytes and 32-bit words, and consider

   char ca [2][3];

I think of this as an array of two "things", each of which is an 
array of three characters.  Can there be an unused byte between
the two "things"?  In other words, are we guaranteed that
(&ca[0][2] + 1 == &ca[1][0])?

It would seem that a lot of bad things could happen if such holes
could exist, but I can't prove that they can't from the dpANS.
Can someone help?

Thanks.

Walter Murray

gwyn@smoke.BRL.MIL (Doug Gwyn ) (02/08/89)

In article <12570007@hpclwjm.HP.COM> walter@hpclwjm.HP.COM (Walter Murray) writes:
>It would seem that a lot of bad things could happen if such holes
>could exist, but I can't prove that they can't from the dpANS.

If you consider what the sizeof the whole array is required to be,
and compare that to the sizeof an element, it should be clear that
there is no room for any such "holes".  A proof should be able to
be worked up from that observation.