The C99 standard refers to double s in the specification for fprintf(which subsequently applies to printf). It states that the argument " doublerepresenting a floating point number is converted ..." Then, in paragraph 9 it says:
If the conversion specification is not valid, the behavior is undefined. If any argument is not the correct type for the corresponding specification, the behavior is undefined.
Therefore, I would expect the following behavior to be undefined, but my compiler does not warn about this.
double d = 2.0;
float f = 2.0f;
printf("%f", d);
printf("%f", f);
On the other hand, the specification for fscanfsays "floating point number" instead of double. This is undefined behavior, as this user claims?
source
share