The TXT files in windows are stored in the form of ASC ⅱ code values. As we all know, the range of ASC 2 code is 0 to 255. values in other ranges cannot be identified. Therefore, values like-1 cannot be converted into corresponding characters that exist in text files. But for binary files,-1 can indeed appear.
The feof () function is used in C/C ++ to determine whether the current file to be operated ends. If the file has ended, the return value is 1; otherwise, 0 is returned. the principle of determining whether a file ends is different from the EOF () function in the database. Feof () is used to determine whether to end the read object based on whether the content is null. The EOF () function is used to determine whether the position of the current Object Pointer has reached the end of the object. This means that feof () is determined based on the content, while efo () is determined based on the position.
The EOF is the end mark of a file. Its value is-1.
Definition: # define EOF (-1)
Definition: # DEFINE _ ioeof ox0010
Definition: # define feof (_ stream)-> flag & _ ioeof)
Feof () is used to determine whether the end of the last file operation is completed. After feof () reads the last character in the file, it will continue to read the content at the next position. If it is null, it indicates that it has reached the end of the file. This will set _ stream-> flag to _ ioeof. To make feof () return 1.
EOF can only be used to determine whether a text file ends. At this time, it checks whether the read character is equal to EOF to determine whether the file ends and feof () does not appear () the problem of determination (the target file will output a byte of content than the source file ). Sometimes EOF cannot be used to replace feof () because it is willing to read the file, an error will also return-1.