This code:
produces this warning:Code:float x; scanf("%f", x);
?I don't understand. I thought %f is for float, and x is a float?Code:warning: format â%fâ expects type âfloat *â, but argument 2 has type âdoubleâ
This code:
produces this warning:Code:float x; scanf("%f", x);
?I don't understand. I thought %f is for float, and x is a float?Code:warning: format â%fâ expects type âfloat *â, but argument 2 has type âdoubleâ
You forgot the &. You need the address of the variable to be able to scan into it.
Quzah.
Hope is the first step on the road to disappointment.
There are two things wrong, one with your code, one with the error message.
First, the error message makes no sense. It says argument 2 is a "double" but it is clearly a float. The compiler is stupid.
Second, you need to pass the ADDRESS of x, not x itself:
Code:float x; scanf("%f", &x);
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}
Heh, I think this is being slightly unfair to the compiler. The float is being promoted to a double so the error message really isn't wrong (the function will be receiving a double); but of course whether the message makes sense depends on whether you think it should refer to the type of the variable you're passing, or the type that's actually being passed (I don't suppose there are many languages where that sentence actually makes sense.)It says argument 2 is a "double" but it is clearly a float. The compiler is stupid.