Mega Code Archive
Determines whether the end of the file has been reached
//Declaration: int feof(FILE *stream);
//Return: A nonzero value: if the file pointer is at the end of the file.
zero: otherwise.
#include
#include
int main(void){
FILE *filep;
if((filep=fopen("testing", "rb"))==NULL) {
printf("Cannot open file.\n");
exit(1);
}
while(!feof(filep)) {
char ch = getc(filep);
printf("%c",ch);
}
fclose(filep);
}