Ugh @ multidimensional arrays. I don't know why everybody likes them so much. Syntax hell.
Re Scipio:
1 2 3 4
|
void function(int** array, int Xsize, int Ysize);
int myArray[Xsize][Ysize];
function(myArray,Xsize,Ysize);
|
This wouldn't work. myArray is not a two stage pointer, it's a 2D array, which is stored the same as a 1D array, just with syntax differences (so it's a one stage pointer, not 2)
The way to do this would be:
1 2 3
|
void function(int array[][6])
{
}
|
Notice that the size of the lowest element(s)
must be known and constant. Only the first pair of brakets can remain empty. You cannot pass the sizes to the function as Scipio suggested (well I suppose you could but it wouldn't make much sense for the lower brakets). That is only possible when the array is created dynamically (in which case it
is a two stage pointer, and Scipio's example would be correct).
Or... you could template the function to make the sizes more dynamic. However that is a bit more complicated and seems like overkill for this.
EDIT:
Doh I totally missed the whole "sub array" thing. XD.
Something similar to what Scipio suggested is probably the best way to go, here. Due to the way these arrays are stored, you can't just extract an arbitrary group of them with a single pointer. Either work with the array in full, or make a class to abstract this behavior.