[prog] c double/float I/O question

dominik.schramm at gmxpro.net dominik.schramm at gmxpro.net
Tue Mar 23 23:21:42 EST 2004


Hi,

Alice Moomlyn <alice_moomlyn at yahoo.com> writes:

>    double mydouble = 42.0;
> [...]
>    printf("Enter a double: ");
>    scanf("%f", &mydouble);

You should use: 
 scanf("%lf", &mydouble);

The "l" indicates that "f" means double (rather than float;
or long int rather than int for "i").
See the man page scanf(3) for details if it's installed on 
your system.

hope this helps,
regards
dominik




More information about the Programming mailing list