Printf '%e' expects type 'double' but argument 2 has type 'double *'

Hey!

I am doing unit testing on my c++ code on VS code windows, however I am stuck with a simple issue. I am trying to print out the output of a test function and compare to something I have. The output is type double (*)[2] and for some reason it seems like I can't use printf("%4.21e\n", output);
I have the error:
format '%e' expects argument of type 'double', but argument 2 has type 'double (*)[2]'

The code is pretty long and messy, however all I am trying to do is printout: potSourcek_inertia in line 667 in testBed. Thank you!

Link:
https://www.zipshare.com/download/eyJhcmNoaXZlSWQiOiIzYTA1MmVlOC1lYjlhLTRkNzktYTkwZS0wMGRkZDBhOWM3NGUiLCJlbWFpbCI6ImFzdHJvbHVqeUBnbWFpbC5jb20ifQ==
Last edited on
Try:

 
    printf("(%.15f, %.15f)\n", (*potSourcek_inertia)[0], (*potSourcek_inertia)[1]);

Last edited on
This is working for me, although giving all zeros but at least it's printing out. Would you care explain what [0] and [1] mean next to the *potSoruceK_inertia?
The fftw_complex type holds a complex number as a 2-element array of doubles. [0] accesses the first element, the real part; [1] accesses the second, the imaginary part. potSourcek_inertia is a pointer to such an array, which is why we need the asterisk (and parens due to precedence) before the [0] and [1].
Topic archived. No new replies allowed.