Message text for ferror() return value
From this reference page:
The ferror() function shall test the error indicator for the stream pointed to by stream.
This means that ferror
returns a boolean that tells you if there is an error or not, nothing more. But according to the POSIX specification the value of errno
will contain an error code in case of a failure.
The library libexplain
can return strings for the ferror. https://linux.die.net/man/3/explain_ferror
From the docs:
if (ferror(fp) < 0)
{
fprintf(stderr, "%s\n", explain_ferror(fp));
exit(EXIT_FAILURE);
}