I have a function that looks like this
float Determinant(unsigned int n, float a[][n])
and I want to pass a double pointer
float **a
is there a way to cast float **a
to float a[][n]
?
I have a function that looks like this
float Determinant(unsigned int n, float a[][n])
and I want to pass a double pointer
float **a
is there a way to cast float **a
to float a[][n]
?
No, there is no way to do that. The array a
, when declared as a function parameter, decays into a pointer to the first element, an array pointer of float (*)[n]
. Neither this array pointer type nor the array float a[][n]
have anything to do with the type float**
.
The need to pass a float**
to this function probably originates from flawed program design. Perhaps you are mistaking dynamically allocated, pointer-based look-up tables for 2D arrays? If so, see Correctly allocating multi-dimensional arrays.