#: 3297 S10/Tandy CoCo
05-May-90 16:07:27
Sb: #3289-C arrays
Fm: Bruce MacKenzie 71725,376
To: Pete Lyall 76703,4230 (X)
Pete,
I must come in on Jeff's side in this debate. An array declaration such
as, char array[4][12], sets up a pointer, array, which points to the bases of
an area of memory large enough for four data objects of length 12 rather than
to 48 data objects of length 1. The distinction seems trivial but it is not.
Now the variable, array, and &array[0][0] are numerically equal, they both
point to the base of the array. However, since when arithmetic is performed on
pointers the size of the object pointed to is automatically factored in, the
two are not equivalent. The expression (array+1) evaluates as a pointer to
element array[1][0], while the expression (&array[0][0]+1) evaluates as a
pointer to element array[0][1].
|