Feof () is a function that is often used to operate files in C language. This function is used to indicate whether we have reached the next position at the end of the file. Both binary and text files work. Compared with EOF (generally defined as-1),
View stdio. h, you can see the following definitions: # define EOF (-1) # DEFINE _ ioeof 0x0010 # define feof (_ stream)-> _ flag & _ ioeof) we can see that the two methods have different principles. Here we will talk about the EOF and feof () macro
Today, I met feof () to determine the end of a multi-output line of the problem, on the Internet to see a well-written article, turn around (transcription) to deepen the impression. Original address: http://blog.csdn.net/flyyyri/article/details/50849
There are two ways to determine the end of a file: EOF and Feof ()To view stdio.h you can see the following definition:#define EOF (-1)
#define _IOEOF 0x0010#define FEOF (_stream) (_stream)->_flag & _ioeof)
From this we can see that the principles
These functions are related to errors in file reading and writing, and are analyzed below:1:ferrorPrototype: int ferror (FILE * fp)Function: Tests whether a file stream is set with an error identifier, or returns 0 if it is a non-0 integer.Example:
There are two methods to determine the end of a file: EOF and feof ()View stdio. h and you can see the following definitions:# Define EOF (-1)
# DEFINE _ ioeof 0x0010# Define feof (_ stream)-> _ flag & _ ioeof)
we can see that the two methods
Introduction: This is a detailed page of the PHP feof () method that requires attention. It introduces PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: //
When fgets reads the last row of the file (the returned result is not null), feof test is false, fgets is performed once (the returned result is null), and feof test is true.
Feof is used to judge whether the stream has reached the end by judging
Because an ascii code is stored in a text file, and FF in the ASCII Code represents a null value (blank), it is generally not used, so if the read file returns ff, the end of the text file is reached. However, if it is a binary file, which may
The problem of using feof () to read files more than once is a classic mistake. This is the case in many schools. After reading the last character of the file, FP-> flag is still not set to _ ioeof, so feof () still does not detect the end of the
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.