Mail Archives: djgpp/1995/02/07/00:54:37
>>>>> "haltmaye" == haltmaye <haltmaye AT mathpool DOT uni-augsburg DOT de> writes:
haltmaye> Format %f in printf expects a float while 100.0 is a
haltmaye> double number. Try %lf or %g.
Wrong! This is a classic C error. Under ANSI C, "%lf" is invalid as
a printf specifier, although many printf implementations accept it.
printf doesn't need a separate %lf because floats are promoted to
doubles. If you don't believe me, try compiling this small test
program using "gcc -Wall":
#include <stdio.h>
void
foo ()
{
printf ("%lf\n", 1.0);
}
gwar:~$ gcc -Wall -c foo.c
foo.c: In function `foo':
foo.c:6: warning: use of `l' length character with `f' type character
-Mat
- Raw text -