Multidimensional arrays are syntax/code poison. I strongly recommend you abandon this idea and encapsulate these structures in a class or something.
That said... to actually answer your question...
Short answer
You have the wrong parameter for 'function'. You must retain the inner array sizes. So in order to pass board[2] to 'function', you must define function like this:
void function(int board[][3]) // <- note: 3, not 9
Long Answer
int board[9][9][3];
A 3D array is an array of arrays of arrays.
So this is an array of 9 arrays of 9 arrays of 3 ints.
To clarify this... let's assign a name to these types:
1 2 3 4
|
int a; // type = 'int'
int b[3]; // type = 'int3', or an array of 3x int
int c[9][3]; // type = 'int93' or an array of 9x int3
int d[9][9][3]; // type = 'int993' or an array of 9x int93
|
'board' in this case would be an 'int993'
board[2]
is accessing the [2] element in the board array.
Since board is an int993, which is an array of int93s, this means that 'board[2]' is of type 'int93'
Since array names can be cast to a pointer to their first element... this means board[2] (while it is an int93) can be cast to a pointer to an int3
Your function:
1 2
|
// I'm changing the param name to 'param' so as not to confuse it with main's 'board'
void function(int param[][9])
|
Here, param is a pointer to an
int9.
We are giving it an array name which is being cast to a pointer to an
int3
An int3 is not an int9
Therefore these pointer types are incompatible, and you will get the error you are seeing.