What is feof in C 1

feof

End-of-file test in a stream.

syntax

parameter

Prank
Pointer to the FILE-Structure.

Return value

The function " feof "returns a non-zero value if a read attempted to read past the end of the file. Otherwise, it returns 0. If the stream pointer zero the function calls the invalid parameter handler as described in Parameter Validation. If further execution is allowed, it will errno on EINVAL set, and that feof returns 0.

For more information about these and other error codes, see _doserrno, errno, _sys_errlist, and _sys_nerr.

Remarks

The feof Routine (implemented both as a function and as a macro) determines whether the end of the Streams was handed over. When the end of file is exceeded, reads return an end of file indicator until the stream is closed or when Rewind, fsetpos, fseecoder clearerr is called for him.

If a file is e.g. b. Contains 10 bytes and you are reading 10 bytes from the file there feof 0 because the file pointer is at the end of the file because you did not try to read past the end. Only after you have tried to read an 11th byte , becomes a Non-zero value returned.

By default, the global status of this function is limited to the application. See Global Status in the CRT for information.

conditions

functionRequired header
feof<stdio.h>

For additional information on compatibility, see Compatibility.

example

Input: crt_feof.txt

output

See also

Error handling
Stream I / O
clearerr
_eof
ferror
perror, _wperror