In the C language, or more accurately, the end of file in the C standard function library ). In the while loop, EOF is used as the end mark of the file, which must be a text file. In text files, data is stored in the form of ASCII code values of characters. We know that the ASCII code value ranges from 0 ~ 255.-1 is not possible, so EOF can be used as the end mark of the file.
File Access or other I/O functions may return a symbolic value (giant set) EOF indicating the end of the file. In fact, the value of EOF is usually-1, but it varies with the system. The huge EOF expands the actual value to the pre-processor before compiling the original code.
In C language, EOF is often used as a sign of the end of a file. There are also many file processing functions whose return values after errors are also EOF. Therefore, it is often used to determine whether a function is successfully called.
And feof
In C language, when data is stored in a binary file, the value-1 is displayed. In this case, EOF cannot be used as the end mark of the binary file. To solve this problem, ansi c provides a feof function to determine whether the file ends. If a file ends, the value of the feof (FP) function is 1. Otherwise, the 0. feof function can be used to determine whether the binary file ends or whether the text file ends.
EOF and feof