Because printf, like any function that work with varargs, eg: int foobar(const char fmt, ...) {}
tries to interpret its parameter to certain type.
If you say "%f"
, then pass c
(as a char
), then printf
will try to read a float
.
You can read more here: var_arg (even if this is C++, it still applies).