Many of the functions described in this chapter return the value of the
EOF to indicate unsuccessful completion of the operation.
EOF is used to report both end of file and random errors,
it's often better to use the
feof function to check explicitly
for end of file and
ferror to check for errors. These functions
check indicators that are part of the internal state of the stream
object, indicators set if the appropriate condition was detected by a
previous I/O operation on that stream.
These symbols are declared in the header file `stdio.h'.
-1. In other libraries, its value may be some other negative number.
The file positioning functions (see section File Positioning) also clear the end-of-file indicator for the stream.
feoffunction returns nonzero if and only if the end-of-file indicator for the stream stream is set.
ferrorfunction returns nonzero if and only if the error indicator for the stream stream is set, indicating that an error has occurred on a previous operation on the stream.
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. For example, all of the functions that perform output to a
implemented in terms of
write, and all of the
conditions defined for
write are meaningful for these functions.
For more information about the descriptor-level I/O functions, see
section Low-Level Input/Output.
Go to the first, previous, next, last section, table of contents.