0% found this document useful (0 votes)
40 views

C Library Function - Feof : Description

C LIBRARY FUNCTION int feof(FILE stream) tests the end-of-file indicator for the given stream. The function returns a non-zero value when End-of-File indicator associated with the stream is set, else zero is returned.

Uploaded by

mmarin1982
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

C Library Function - Feof : Description

C LIBRARY FUNCTION int feof(FILE stream) tests the end-of-file indicator for the given stream. The function returns a non-zero value when End-of-File indicator associated with the stream is set, else zero is returned.

Uploaded by

mmarin1982
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

http://www.tutorialspoint.com/c_standard_library/c_function_feof.htm Copyright tutorialspoint.

com
C LIBRARY FUNCTION - FEOF()
Description
The C library function int feof(FILE *stream) tests the end-of-file indicator for the given stream.
Declaration
Following is the declaration for feof() function.
int feof(FILE *stream)
Parameters
stream -- This is the pointer to a FILE object that identifies the stream.
Return Value
This function returns a non-zero value when End-of-File indicator associated with the stream is set, else zero is
returned.
Example
The following example shows the usage of feof() function.
#include <stdio.h>
int main ()
{
FILE *fp;
int c;
int n = 0;

fp = fopen("file.txt","r");
if(fp == NULL)
{
perror("Error in opening file");
return(-1);
}
while(!feof(fp))
{
c = fgetc(fp);
printf("%c", c);
}

fclose(fp);

return(0);
}
Assuming we have a text file file.txt, which has the following content. This file will be used as an input for our
example program:
This is tutorialspoint.com
Let us compile and run the above program, this will produce the following result:
This is tutorialspoint.com

You might also like