In C you have the "%c"
and "%f"
formats flags for printf
- and scanf
-like functions. Both of these function use variable length arguments ...
, which always convert floats
to doubles
and chars
to ints
.
My question is, if this conversion occurs, why do separate flags for char
and float
exist? Why not just use the same flags as for int
and double
?
Related question:
Why does scanf() need "%lf" for doubles, when printf() is okay with just "%f"?
Because the way it gets printed out is different.
printf("%d \n",100); //prints 100
printf("%c \n",100); //prints d - the ascii character represented by 100
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With