I\'ve never bothered to look for printf as I started learning C++ without C. Now i want to use formatted output in some project. so I\'m looking for some references that can exp
It actually invokes undefined behavior (UB). If the format specifier doesn't match with the type of the argument passed to printf
, then it is UB, which means anything could happen. It can print 0
, or 9878978
or any garbage. Anything, entirely unpredictable, could happen.
Use %f
if the data type of the argument is float
.