Mail Archives: djgpp/1993/01/08/10:00:06
(In cases like this, it is hard to tell what he meant...)
>Richard Shields <src4src!mcdhup!rutgers!sequent.com!richards> writes:
>>
>> Has anyone had any trouble using scanf to read in a floating point value?
>>
>> I tried this in my code:
>>
>> double amount;
>>
>> scanf("%f", amount);
>> printf("amount = %10.2f\n", amount);
>>
>>
>> When I run the program and enter 4.25 the printf statement prints 0.00.
>>
>You told scanf to read in a "float", not a "double". Need to say "%lf".
Maybe he meant to declare amount as float.
Also, the program would probably work if he put a star after the comma
in the printf() call. (Kids, don't try this at home...)
Please - no flames. Dollar bills gratefully accepted, however.
Send to: Box 166011, Chicago, IL., 60616-6011
- Raw text -