1

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]?

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.