Need help inputting Float #'s

Karl Heuer karl at haddock.ima.isc.com
Fri Jul 20 04:06:19 AEST 1990


In article <2834 at elrond.CalComp.COM> shodsdon at elrond.UUCP (Steve V. Hodsdon) writes:
>In article <hart.648221206 at blackjack> hart at blackjack.dt.navy.mil (Michael Hart) writes:
>>Please respond via E-mail...
>
>Tried to, can't get there from here :-)

Please, folks, don't use USENET as a substitute for faulty mail.  If your
mailer can't understand the address, then just sit on your hands and let
somebody else answer the question.  (Especially when your answer is wrong,
'cause then we gurus might have to do damage control.)

>>        sscanf(buffer,"%f%n",&number,&c1);
>                        ^^ -> should be %lf

`%lf' is the correct scanf format for objects of type `double', but (after
fixing the bug that he had an extra `*' in all the declarations) the type of
the object in question was `float', for which `%f' is indeed correct.

(Note that the situation is different for printf, where the context is such
that float would promote to double, so `%f' serves for both.)

Karl W. Z. Heuer (karl at kelp.ima.isc.com or ima!kelp!karl), The Walking Lint



More information about the Comp.lang.c mailing list