Doubt - Static multidimension arrays

albert00 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jan 18 23:21:39 PST 2016


On Tuesday, 19 January 2016 at 04:50:18 UTC, tsbockman wrote:
> On Tuesday, 19 January 2016 at 03:20:30 UTC, albert00 wrote:
>> [...]
>
> ... what you're making is an array *of arrays*:

Maybe I was misunderstood, because in fact that is what I was 
making an array of arrays, but my problem in fact was in 
accessing it.

Like I said above:

I was declaring int[1][2] arr:

But to access I need to invert the columns like:

	arr2[0][0] = 1;
	arr2[1][0] = 2;


> int[10][5] a; // An array of 5 (int[10])

Using your example, in my head I'd access the last element as:

a[9][4] but that would give me an error:

Error: array index 9 is out of bounds arr[0 .. 5]

So I need to invert a[4][9].

Again seems a bit strange "FOR ME" since I declare in one way and 
access the other way.

albert.

PS: I'm changing my name because I think there is another user 
with the same name, that Icon is not mine.


More information about the Digitalmars-d-learn mailing list