Neophyte seeks scanf() help
Mark Chandler
chandler at kinetics.com
Wed Mar 6 12:19:19 AEST 1991
The News Manager)
Nntp-Posting-Host: plasma
Organization: Novell, Walnut Creek CA.
Distribution: na
Date: Mon, 4 Mar 1991 23:31:41 GMT
I just started a C programming class a few weeks ago and
have run into a problem that I can't figure out. I have
a *very* simple funtion that prompts the user to input a
number and then echoes it back. The function is:
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
^^^^^^
Can someone explain what's going on here? I'm running
THINK C v4.02 with the TCL, scanf(), and color.h updates
on a Mac IIsi.
*Any* help is greatly appreciated.
Mark Chandler | The opinions expressed above
chandler at wc.novell.com | are mine, not my employer's.
More information about the Comp.lang.c
mailing list