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
When you write printf("%d", f);
the type of f
must be int. The code as you have written it invokes undefined behaviour. Taken from an answer to a similar question:
in the documentation for fprintf (7.19.6.1/9) which also applies to printf, it explicitly states that if any argument is not the correct type for the format specifier - for an unmodified %d, that is int - then the behaviour is not defined.
Why does it print zero?
Maybe they ran out of nasal demons?