NO

Author Topic: Error message "expecting double but found double *"  (Read 3562 times)

Hankering4u

  • Guest
Error message "expecting double but found double *"
« 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 *'.

CommonTater

  • Guest
Re: Error message "expecting double but found double *"
« Reply #1 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.