What is wrong in below
int data[2][2] = { {1,1}, {2,2}};
int sum = sum(data, 2);
Sum is defined as
int sum(int **data, int rows);
data contains the address of the data[0]
, so it can be treated as a pointer. The *data
leads me to the value, which is another array of type int
. This another array should be treated as pointer to first element. Hence why do compiler complains at the argument for int **data
?
I get a compiler error as show below. I understand the error, but my question is why **data
is not acceptable.
error: cannot convert int (*)[2] to int** for argument 1 to int sum(int**, int)