When a stdio
stream encounters an error (but not EOF), the stream's error indicator will be set so that ferror()
will return nonzero. I have always assumed that more information is available in errno
. But how do I know this?
Documentation for some functions [e.g. man fopen
under Linux] says that errno
will also be set. However man fgets
doesn't mention errno
at all. The glibc info pages are reassuring:
In addition to setting the error indicator associated with the stream, the functions that operate on streams also set `errno' in the same way as the corresponding low-level functions that operate on file descriptors.
But I have no idea how strong this guarantee is. Is it required by the C standard? What happens in Visual C/C++?