Let's say I have a declaration of a two-dimensional array:
int array[4][2] = { { 0, 2 }, { 1, 8 }, { 2, 4 }, { 3, -10 } };
I have a function that takes a two-dimensional array as a parameter:
void sort( int **, int );
...
void sort( int **array, int arraylength ){
...
}
I pass the array to the function by value, like so:
sort( array, 4 );
I get the following error:
frequency.c:53:8: warning: passing argument 1 of 'sort' from incompatible pointer type [-Wincompatible-pointer-types]
sort( array, 4 );
^~~~~
How is the type incompatible? My understanding is that all array variables are treated as pointers, so I'm just passing an int pointer pointer to a function that takes an int pointer pointer as a parameter, effectively passing the data in the array by reference. The only difference is that the function prototype uses array notation for the parameter while the declaration of the array uses the regular static array notation. Are statically declared arrays somehow different from dynamically declared arrays?