0

I am trying to pass a row of a multidimensional array to a function as pointer. The 3d arrays are stores inside the following structure.

typedef struct{
double complex CUR[MAX_CHANNELS][MAX_HARM][4];
double complex VOL[MAX_CHANNELS][MAX_HARM][4];
}VALS;

I am trying to pass one row into the following function as a parameter.

void foo(double complex *V,double complex *I);

In the main program I am passing the first row as a pointer. But in the execution I am getting an "incompatible pointer type warning".

foo(&VALS.VOL[2][0],&VALS.CUR[2][0]);
1
  • 1
    You don't need &. Arrays automatically decay to pointers when used as function arguments. Commented Aug 7, 2020 at 0:15

1 Answer 1

1

Since the third dimension is still an array, the resulting type of vals.VOL[2][0] and vals.CUR[2][0] is of type double* (pointing to the first element of the array). therefore a & is not needed:

foo(vals.VOL[2][0], vals.CUR[2][0]);
Sign up to request clarification or add additional context in comments.

Comments

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.