RAD Studio |  |

feof

Header File

stdio.h

Category

Input/output Routines

Prototype

int feof(FILE *stream);

Description

Detects end-of-file on a stream.

feof is a macro that tests the given stream for an end-of-file indicator. Once the indicator is set read operations on the file return the indicator until rewind is called or the file is closed. The end-of-file indicator is reset with each input operation.

Return Value

feof returns nonzero if an end-of-file indicator was detected on the last input operation on the named stream and 0 if end-of-file has not been reached.

Example

Copy Code

    #include <stdio.h>
    int main(void)
    {
       FILE *stream;
       /* open a file for reading */
       stream = fopen("DUMMY.FIL", "r");
       /* read a character from the file */
       fgetc(stream);
       /* check for EOF */
       if (feof(stream))
          printf("We have reached end-of-file\n");
       /* close the file */
       fclose(stream);
       return 0;
    }

Portability

POSIX | Win32 | ANSI C | ANSI C++
+ | + | + | +

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!