Relationship between EOF and feof () Functions

Source: Internet
Author: User

In the C language, or more accurately, the end of file is represented in the C standard 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.

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.


From the column of ainemo

Related Article

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.