End-of-file

From Wiki @ Karl Jones dot com
Jump to: navigation, search

In computing, end-of-file (commonly abbreviated EOF) is a condition in a computer operating system where no more data can be read from a data source.

Description

The data source is usually called a file or stream.

In general, the EOF is either determined when the reader returns null as seen in Java's BufferedReader, or sometimes people will manually insert an EOF character of their choosing to signal when the file has ended.

In the C Standard Library, the character reading functions such as getchar return a value equal to the symbolic value (macro) EOF to indicate that an end-of-file condition has occurred.

The actual value of EOF is system-dependent (but is commonly -1, such as in glibc) and is unequal to any valid character code.

Block-reading functions return the number of bytes read, and if this is fewer than asked for, then the end of file was reached or an error occurred (checking of errno or dedicated function, such as ferror is often required to determine which).

See also

External file