Name | Description | Notes | Source | Availability | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|
clearerr() |
Clear error flag on stream | (·) | <stdio.h> |
C89 | C90 | C95 | C99 | C11 | |||
EOF |
End-of-stream indicator | M | Headers | C89 | C90 | C95 | C99 | C11 | |||
feof() |
Test for end of stream | (·) | <stdio.h> |
C89 | C90 | C95 | C99 | C11 | |||
ferror() |
Test for stream error | (·) | <stdio.h> |
C89 | C90 | C95 | C99 | C11 | |||
WEOF |
End-of-stream indicator | H | M | Headers | C95 | C99 | C11 | ||||
WINT_ |
Maximum value of
wint_t |
H | M | <stdint.h> |
C99 | C11 | |||||
WINT_ |
Minimum value of
wint_t |
H | M | <stdint.h> |
C99 | C11 | |||||
wint_t |
Wide-character or error type | H | T | Headers | C95 | C99 | C11 |
#include <stdio.h>
int ferror(FILE *stream);
void clearerr(FILE *stream);
int feof(FILE *stream);
Every stream has
an error indicator, initially clear. ferror
returns non-zero if the error indicator of stream
is set. clearerr
and rewind
clear the error indicator of
stream
.
Unless a stream is unlimited, reading from it will
eventually reach its end. Every stream has an
end-of-file indicator, which is set when
attempting to read beyond the end of the stream. feof
returns non-zero if the end-of-file indicator of stream
is set. clearerr
also clears the end-of-file indicator. Note that the EOF
indicator is set only after attempting to read beyond
the end, not merely when the end has been
reached.
Byte-oriented functions like fgetc
return an unsigned byte as an
int
so that
they can also return a negative value to indicate
end-of-file. Symbolically, this value is EOF
,
defined in <stdio.h>
and
<ctype.h>
. Wide-oriented
equivalents like fgetwc
similarly return a type
wint_t
that can hold either a wchar_t
or an end-of-file
indicator, WEOF
,
defined in <wchar.h>
and <wctype.h>
.
wint_t
has the range WINT_
to WINT_
,
defined in <stdint.h>
.