Mail Archives: djgpp/1998/11/29/09:48:37
I have a problem with "feof" and "fseek".
What I did, was the following.
#include<conio.h>
#include<stdio.h>
void main(void)
{
FILE *f;
clrscr();
f=fopen("binary_file","rb"); /*open files in binary-mode for reading
*/
if (f==NULL) /* check if file exists; if not print
error-message and exit */
{
printf("Error !\n");
getch();
exit(1);
}
while(feof(f)==0)
{
fseek(f,1,SEEK_CUR);
}
fclose(f);
}
This program should increase the filepointer by one byte, everytime
the loop is executed until EOF is reached.
"feof" return 0 if the EOF is not reached. Otherwise it returns a
value, different from 0.
So the loop should be executed until "feof" says that EOF is reached,
shouldn't it ?
But it doesn't. The loop isn't aborted and has no end.
- Raw text -