As above, say I have a 3 dimensional array, a[][][], and I want to pass this to a f开发者_运维百科unction; how should I declare the function parameter?
void function1(int array[][3][4])
{
...use array here...
}
void function2(void)
{
int array[20][3][4];
...load array...
function1(array);
}
Just declare a triple pointer
int functionName(int*** arrayPtr, int x, int y, int z){
return arrayPtr[z][y][x];
}
I would send a pointer to pointer to pointer with all dimensions.
void foo(int ***ar, size_t l, size_t m, size_t n)
{ /* ... */ }
精彩评论