Neophyte seeks scanf() help
David Ebbo
dsebbo at dahlia.uwaterloo.ca
Sat Mar 9 14:37:25 AEST 1991
>From: chandler at kinetics.com (Mark Chandler)
>
>float get_tax(void)
>{
> float tax;
>
> printf("Enter the tax: ");
> scanf("%f", &tax);
> printf("The tax is %.4f\n", tax);
>
> return tax;
>}
>
>Running it produces the following:
>
>Enter the tax: 0.01
>The tax is 0.1000
> ^^^^^^
That looks like a bug in your compiler, since your code is fine.
I tried it on gcc, and it worked fine (i.e. The tax is 0.0100).
David Ebbo.
More information about the Comp.lang.c
mailing list