
Simple scanf/printf question
Quote:
>>For the floating-point input conversions, the default argument type is
>>float* . (This is different from the corresponding output conversions,
where
>>the default type is double ; remember that float arguments to printf are
>>converted to double by the default argument promotions, but float *
>>arguments are not promoted to double * .) You can specify other sizes of
>>float using these type modifiers:
>Doesn't this violate the ANSI standard or am I missing something? I
>have always throught (see also Kernighan & Ritchie) that for printf(),
>you should use %g for floats and %lg for doubles. However, when using
>%lg, GCC gives me the warning: "use of 'l' length character with 'g'
>type character".
AFAIK floats are converted to doubles when they're passed to an
unprototyped (e.g. std/var args) function anyway, so I couldn't see the
point in using a special indicator when, from printf's point of view,
both types will be passed in as a double. K&R volume 1 says that
the length modifier 'l' "indicates that the corresponding data item is
a long rather than an int", so it would seem not to have been relevant
to floats at all. Of course K&R vol. 1 is a bit old now. I've brought
this thread into comp.lang.c where you can get a definitive answer;
if anyone in c.l.c wants to read the earlier posts in this thread, try
DaveK
--
They laughed at Galileo. They laughed at Copernicus. They laughed at
Columbus. But remember, they also laughed at Bozo the Clown.