Doubt - Static multidimension arrays

albert00 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jan 18 19:20:30 PST 2016


Well maybe it was my fault, but anyway, here's a small example of 
what I was working on:

void main(){
	// Array 1	
	int[2][2] arr1;

	arr1[0][0] = 1;
	arr1[0][1] = 2;
	arr1[1][0] = 3;
	arr1[1][1] = 4;

	// Array 2
	int[1][2] arr2;
	
	//arr2[0][0] = 1;
	//arr2[0][1] = 2; // <- Error
	
	arr2[0][0] = 1;
	arr2[1][0] = 2;
}

So for what I can see on Array 2 is the column/row works 
otherwise.

It's strange since I was declaring int[1][2] (1 row / 2 columns) 
and then accessing as:

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

Seems like 2 rows and 1 column. This makes sense?


More information about the Digitalmars-d-learn mailing list