2 ms·
Right, in this instance the behaviour is identical, but that wasn't my point. In the interests of defensive programming, it makes sense to stick with the simpl
by MaxBarraclough 6y ago
Right, in this instance the behaviour is identical, but that wasn't my point.
In the interests of defensive programming, it makes sense to stick with the simpler and safer function unless there's a good reason to use the more complex and more dangerous function. printf should be used only when necessary. In a hello world, it's not necessary.
> Using a literal is perfectly safe and the intended usage.
It's not strictly true that it's perfectly safe. The literal could accidentally contain %n which would cause undefined behaviour. A little contrived, but consider Something has gone really #$@&%n£ wrong!
It's roughly the intended usage of printf, but it's precisely the intended usage of puts / fputs. Using them closes the door completely on format-specifier bugs.