Date: Fri, 8 Jan 93 08:57:56 CST From: "Jeremy Mathers" To: alane AT wozzle DOT linet DOT org Subject: Re: scanf woes Cc: djgpp AT sun DOT soe DOT clarkson DOT edu (In cases like this, it is hard to tell what he meant...) >Richard Shields 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