Don't understand how to access array with function

Okay, so I have a few multidimensional arrays that I would like to pass to a function so the function can do things with them. Here's a simplification of what I'm trying to do.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#define WIDTH 10
#define HEIGHT 10

int testarray1[WIDTH][HEIGHT];
int testarray2[WIDTH][HEIGHT];
int indexCounter;

void instantiateTestArray (int[WIDTH][HEIGHT] inputArray) {
	indexCounter = 0;
	for (int index1 = 0; index1 < WIDTH; index1++) {
		for (int index2 = 0; index2 < HEIGHT; index2++) {
			inputArray[index1][index2] = indexCounter++;
		}
	}
}

int main (int argc, char **argv) {
	instantiateTestArray(testArray1);
	instantiateTestArray(testArray2);
}


(I am not actually trying to number all the cells in order, I'm just using a simple example so I don't muddy the problem)

So, it says I need a ')' before inputArray on the function declaration line, which doesn't make much sense to me, because how will I access the data that gets passed? I tried going back and redefining my arrays as a multidimensional array of pointers so I could pass a pointer to it instead but the arrays have a lot of dimensions and are very large and the system runs out of memory. And, apparently I had to specify the exact size of the array I passed to the function, because without specifying it didn't like it either. How do I do this?
Change the function header to:
void instantiateTestArray (int inputArray[WIDTH][HEIGHT] ) {

though it should also work if the first dimension is omitted, like this:
void instantiateTestArray (int inputArray[][HEIGHT] ) {
OH! Derp. Okay, that did it. Thank you so much.

I have been staring at this for too long, I think!
Topic archived. No new replies allowed.