Home » C programs » stdio.h header file functions

feof() function in C language with Example

Here, we are going to learn about the feof() function of library header stdio.h in C language with its syntax, example.
Submitted by Souvik Saha, on January 06, 2019

feof() function in C


    int feof(FILE* filename);


    FILE *filename

Return type: int(0 or 1)

Use of function:

In C language when we are using a stream that links with a file, then how can we determine we come to the end of a file. To solve the problem we have to compare an integer value to the EOF value. Through the feof() function we determine whether EOF of a file has occurred or not. The prototype of this function is int feof(FILE* filename);

It returns the value zero when end of the file has not occurred, otherwise it returns 1.

feof() example in C


int main()
	FILE *f;
	char str[100];
	//Check the existence of that file
		printf("Cannot open the file...");
		//if not exist program is terminated
	printf("File content is--\n");
	//print the strings until EOF is encountered
		//print the string
	//close the opened file
	return 0;


feof example in c

Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.