Hello everyone, I'm trying to send a non-const two-dimensional array to a function that receives it as const 2-dimensional array, but the compiler (GNU GCC Compiler) issues the following warning in the function call:
" warning: passing argument 1 of 'receiveArray' from incompatible pointer type ".
Also, it issues the following warning in the function prototype:
" note: expected 'const int (*)[2]' but argument is of type 'int (*)[2]' ".
The code is:
If I declare array as const int, the program is compiled without warning - so, is there a way to send a non-const double-subscripted array to a function and that function to receive it as const? I know it is possible with 1-dimensional arrays. Thanks in advance!Code:#include <stdio.h> /* Function prototype: */ void receiveArray(const int array_copy[][2]); int main(void) { int array[2][2] = { { 2, 1 }, { 1, 4 } }; receiveArray(array); return 0; } void receiveArray(const int array_copy[][2]) { printf("Array received successfully.\n"); }