EOF-a constant that represents the end of the file

EOF is a constant that represents the end of the file. Although defined as a negative number in the C language specification, it is generally defined as "-1". You can use it by reading the stdio.h header.

EOF

fgetc function, getc function, getchar function, etc. reach the end of the file If so, it returns EOF.

However, do not use this value to determine that you have actually reached the end of the file. If one character of the read file is the same as EOF, a misjudgment will occur. Use the feof function in conjunction with the EOF check to determine that you have reached the end of the file. See the sample code for the fgetc function for the actual code.

Associated Information