www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1993/01/08/09:00:06

To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: scanf woes
From: alane AT wozzle DOT linet DOT org (J. Alan Eldridge)
Date: Thu, 07 Jan 93 23:16:24 EST
Organization: Disorganization

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".


alane AT wozzle DOT linet DOT org (J. Alan Eldridge)
Fido: The University of Walamaloo 1:272/38.473

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019