I
Ioannis Vranos
The questions are about C95.
printf() questions:
1. printf() provides "%f" format specifier for double. Usually
implemented as a variadic function how can it discern if the argument is
float or double? Shouldn't we cast to double when passing a float value?
If an implicit conversion takes place, at what stage does it take place?
Consider as an example:
printf("%f\n", 123.45F);
2. The same question also applies when printing a signed char value with
"%d" format specifier.
scanf() questions:
1. scanf() provides the "%f" specifier for float. How can it discern
when we pass a double?
Example:
double x;
scanf("%f", &x);
If an implicit conversion to double takes place, at what stage does it
take place? Also if such conversion takes place how it works when using
a float variable?
Example:
float b;
scanf("%f", &b);
printf() questions:
1. printf() provides "%f" format specifier for double. Usually
implemented as a variadic function how can it discern if the argument is
float or double? Shouldn't we cast to double when passing a float value?
If an implicit conversion takes place, at what stage does it take place?
Consider as an example:
printf("%f\n", 123.45F);
2. The same question also applies when printing a signed char value with
"%d" format specifier.
scanf() questions:
1. scanf() provides the "%f" specifier for float. How can it discern
when we pass a double?
Example:
double x;
scanf("%f", &x);
If an implicit conversion to double takes place, at what stage does it
take place? Also if such conversion takes place how it works when using
a float variable?
Example:
float b;
scanf("%f", &b);