Error Handling for Input/Output Functions
Errors
on
file access are
indicated by the return value of the file access function. When the
end of a file is encountered by a read function, for example, the
symbolic constant EOF (for byte-oriented files) or
WEOF (for wide-oriented files) is returned. If a
read or write error has occurred, an error flag is also set in the
FILE structure.
Furthermore, in reading or writing wide-oriented streams, errors can
occur in the conversion between wide characters of type
wchar_t and multibyte characters in the stream.
This is the case if one of the conversion functions
mbrtowc() and wcrtomb() does
not return a permissible value. The global error variable
errno then has the value EILSEQ
(“error: illegal sequence”).
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access