The function that I'd like to call is as follows.
void func(int rows, int columns, int matrix[rows][columns]) {
cout << matrix[rows-1][columns-1] << endl;
}
The Clion compiler told me that the real type of the matrix is int(*)[columns]
.
I tried many ways to pass the parameter but all failed when run the func
. Here are some of my ways of passing parameters.
It seems that the length of the array pointed to by the formal parameter matrix
is a variable. But should't an array pointer should declare the size of columns?
Why the func
could pass compilation?
If this is reasonable, how to pass parameters to func
?