Pelles C forum

C language => Beginner questions => Topic started by: Hankering4u on March 14, 2011, 12:27:12 AM

Title: Error message "expecting double but found double *"
Post by: Hankering4u on March 14, 2011, 12:27:12 AM
I know this is elementary. Since new to this language and finding a sillier question in this forum, I found the courage to ask.

double x;
x = 12.5;
printf("%4.1f", &x);

warning #2234: Argument 2 to 'printf' does not match the format string; expected 'double' but found 'double *'.
Title: Re: Error message "expecting double but found double *"
Post by: CommonTater on March 14, 2011, 12:46:19 AM
When using scanf() you need the &x (address of x) so it knows where to place the value you input.
However when printing it already knows how to read x is so you can use prinf("%4.1lf",x); without the address of marker.