just a few small questions

Derek Parnell derek at psych.ward
Sat Apr 15 13:13:53 PDT 2006


On Sun, 16 Apr 2006 04:28:45 +1000, Bruno Medeiros  
<brunodomedeirosATgmail at SPAM.com> wrote:

> Derek Parnell wrote:
>>  One major difference from C arrays is that the indexes are *used* in  
>> the reverse order from C. Meaning that in C one would write ...
>>     item = a[X][Y];
>>  but in D one writes ...
>>     item = a[Y][X];
>>  --Derek Parnell
>> Melbourne, Australia
>
> This is not correct, I belive (or at leas mis-explained) . Only D array  
> declaration and C array declaration have a different order. The array  
> *usage*, or rather, the indexing of an array works the same. That is, in  
> both C and D:
>    //The X element is accessed first, and then the Y element is accessed
>    item = a[X][Y];

What I meant was in D if one declares ...

    int[Columns][Rows] A;

then in D you access the elements as

    A[Row][Col];

and not

   A[Col][Row];

but in C (which I'm really very rusty in) you would declare

   int A[Rows][Columns];

and access it as

   A[Row][Col];

-- 
Derek Parnell
Melbourne, Australia



More information about the Digitalmars-d-learn mailing list