scanf doesn't work for variables of type double

Conor P. Cahill cpcahil at virtech.UUCP
Sat Sep 16 10:34:14 AEST 1989


In article <12988 at uhnix1.uh.edu>, jsmng at csune.cs.uh.edu writes:
> Does anyone have any experience with this? According to K&R, %f for
> double should be allowed in scanf.

This is not true.  %f is allowed for doubles in printf since float
parameters are automatically converted to doubles, but for scanf() you
must use %lf for doubles.  See K&R1 pg 149, K&R2 pg 158,  
or RTFM scanf(2) man page.


-- 
+-----------------------------------------------------------------------+
| Conor P. Cahill     uunet!virtech!cpcahil      	703-430-9247	!
| Virtual Technologies Inc.,    P. O. Box 876,   Sterling, VA 22170     |
+-----------------------------------------------------------------------+



More information about the Comp.lang.c mailing list