On 4/9/2011 12:34 PM, James Kuyper wrote:
> On 04/09/2011 12:05 PM, Ioannis Vranos wrote:
>> Hi all,
>>
>> Is it guaranteed that ==> all C implementations, implement
>> two-dimensional�
>> arrays in the style:
>>
>>
>> Logical:
>>
>> A11 A12 A13
>> A21 A22 A23
>> A31 A32 A33
>>
>>
>> Physical:
>>
>> A11 A21 A31 A12 A22 A32 A13 A23 A33
>>
>>
>> that is, column after column (and not line after line)?
>
> Assuming
>
> int a[3][3]
>
> and assuming that by A12 you are referring to a[0][1], then yes, this is
> guaranteed.
ITYM "guaranteed false." (Either that, or we're both having
trouble with the O.P.'s notation.) Putting it purely in C terms:
int a[3][3];
assert (&a[0][1] == &a[0][0] + 1);
assert (&a[0][2] == &a[0][0] + 2);
assert (&a[1][0] == &a[0][0] + 3);
...
assert (&a[2][2] == &a[0][0] + 9);
/* Also, noting that the "stride" is different: */
assert (&a[1] == &a[0] + 1);
assert (&a[2] == &a[0] + 2);
--
Eric Sosman
d