In one of my University Projects, I got points off and feedback from my professor saying I didn't handle printf
errors.
In English --> / * ### FB: Error handling printf () is missing * /
/* ### FB: Fehlerbehandlung printf() fehlt */
printf("%7lu %8lld %10s %3lu %-8s %-8s %8lu %12s %s %s %s\n",
sb->st_ino, nblks, permstr, (unsigned long) sb->st_nlink,
username, groupname, sb->st_size,
ntime, filename, (symlink ? "->" : ""),
(symlink ? symlink : "")
);
My question is, is it really important to always check return value of the printf
function and handle the errors? Even if I find an error I will still use fprintf
to print to stderr
, for which I have to check the return type for fprintf
again.
So when should the return value be checked, and how should it be handled?