May 2021 2 434 Report
format ‘%lf’ expects type ‘double *’, but argument 2 has type ‘double’?

I'm writing a simple code, just to teach myself C. I get the following errors when I compile:

21: warning: format ‘%lf’ expects type ‘double’, but argument 5 has type ‘complex double’

28: warning: format ‘%lf’ expects type ‘double *’, but argument 2 has type ‘double’

30: warning: format ‘%lf’ expects type ‘double’, but argument 2 has type ‘complex double’

I guess my question is what does the * denote, and what to I declare my variable to be (as in %?) to avoid it.

It also transpires that I get the wrong answer at the end of it all. Would this be due to the above?

Update:

So, that's my code. I was having trouble writing even this before, which is why it's quite slow to get going. I wanted to go through each step before I combined them. It was a case of a missing "&" in the second error, thank you! It makes sense of the Euler formula perfectly the first time, but then gives the wrong solution the second time around. By typing "1 0 1", the second part reduces to the first, but putting in a value of pi gives 1, rather than the -1 it gave above. It seems bizarre to me that this would be the case. I can only assume it finds a fault in my "1*(cos(arg)+I*sin(arg)) + B1*(cos(-arg)+I*sin(-arg)))" bit.

Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Helpful Social

Copyright © 2024 1QUIZZ.COM - All rights reserved.