Now come on, Tater, you're making fun of me.
Now come on, Tater, you're making fun of me.
There is something called a format string attack, but printf("%s", something); prevents it so percents or anything else aren't really a problem.
That being said, I would think that the only reason printf would fail, being used normally, is if stdout was never opened. And in general, I would depend on ferror() and perror() actually get useful information about what went wrong with a stream operation, rather than just a number.
You probably want to create a temporary new file, remove the old one, and then rename the new file the same as the old one. That way if something does go wrong while dumping the original file is unchanged.