Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!uhccux!munnari.oz.au!cs.mu.oz.au!ok From: ok@cs.mu.oz.au (Richard O'Keefe) Newsgroups: comp.lang.c Subject: Re: scanf doesn't work for variables of type double Message-ID: <2117@munnari.oz.au> Date: 16 Sep 89 06:15:21 GMT References: <12988@uhnix1.uh.edu> Sender: news@cs.mu.oz.au Lines: 18 In article <12988@uhnix1.uh.edu>, jsmng@csune.cs.uh.edu writes: >[having trouble with scanf("%f", &double_var)] > Does anyone have any experience with this? According to K&R, %f for > double should be allowed in scanf. We are running SunOS 4.0.1 and > I think our C compiler follows the K&R standards (as opposed to ANSI). K&R 1st edition section 7.4 page 149: f a floating-point number is expected; the corresponding argument should be a pointer to a FLOAT. ... the conversion characters e or f may be preceded by l to indicate that a pointer to DOUBLE rather than a pointer to FLOAT is in the argument list. Ever since K&R1 it has been the case that %e and %f in scanf() required pointer-to-float in the argument list, while if the argument list had pointer-to-double the format had to be %le or %lf. X3J11 didn't change that. [I cite the Old Testament here because the original poster appealed to it.]