feof() function in C
feof( ) function in C, is basically used for serching end of file in the stream(file).
![]() |
| feof() function |
Through this article you will resolve your following doubts which are listed below,
- feof() function in c
- header file for feof() function in c
- return value of feof() function in c
- feof() function in c syntax
- feof() function in c program
feof( ) functio in C
feof function is also a standard library function of C which is used in file handling, C feof function is used to determine if end of the file(stream), specified has been reached or not. This function keep on searching the end of the file(eof) in your file program.
Header file for feof( ) function in C
This function is also define in <stdio.h> file which is stand for standard input- output header file.
Return value of feof( ) function in C
This function return a non-zero value when EOF indicator associated with stream is set else zero is returned.
Syntax of feof( ) function in C
int feof(FILE *stream)
Example of feof() function in C
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *w;
char ch;
clrscr();
/* --- OPEN FILE FOR WRITE AND READ DATA --- */
w=fopen("yourfile.txt","w+r");
/* --- WRITE DATA INTO THE FILE --- */
printf("Enter Text: ");
while((ch=getchar())!=EOF)
fputc(ch,p);
/* --- RESET FILE POINTER POSITION AT BEGINNING --- */
rewind(p);
/* --- READ DATA FROM THE FILE --- */
ch=fgetc(p);
while(!feof(p))
{
printf("%c ",ch);
ch=fgetc(p);
}
/* --- CLOSE FILE --- */
fclose(p);
getch();
}
Conclusion
feof( ) function in C, is basically used for serching end of file in the stream(file).
