field width in scanf for reals

Mike Engber engber at shorty.CS.WISC.EDU
Wed May 24 03:39:43 AEST 1989


I've found that when reading reals in exponential format using scanf
with a field width specifier that the e for the exponent doesn't seem
to count as part of the field width. To read 1.2e3 you need to use
"%4f". I've tried this out on several UNIX machines and they all seem
to have the same bug/feature. The SUN compiler, however, worked as
you'd expect.  It needed a field width of 5.

Does anyone have an explanation of all this. I assume it's compiler bugs.

please respond via email

-ME



More information about the Comp.lang.c mailing list