[comp.sys.mac.programmer] Neophyte seeks scanf

chandler@kinetics.com (Mark Chandler) (03/06/91)

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@wc.novell.com     |     are mine, not my employer's.