Well, technicaly, you can pass a stack array around using this method:
Code:
func(int arr2d[][20], ...) ...
The problem with any multidimensional arrays is that you do need to know the size of all dimensions besides the left-most one, because all C arrays are essentially 1D arrays, with a suitable calculation to achieve the location of the dimensions. The same applies when you allocate on the heap or if you create a global variable -it is only chunk of linear memory in every case.
--
Mats
Yeah, that's what I meant by Pass the 2d array as a parameter. You can also do this to force the first parameter to be the same:
Code:
void func(int (&arr2d)[10][20]);
This also has the effect of making sizeof(array) be the actual size of the array.
Last edited by King Mir; 10-11-2007 at 11:52 AM.
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.