EOF and feof

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.