Mail Archives: djgpp/2000/05/10/22:12:58
> Well, after a good several hours of debugging, I finally discovered
> that feof(FILE *) does NOT work the same under DJGPP as it does
> under other compilers.
I compiled your program under both DJGPP and Linux. They do exactly
the same thing. The reason there's an extra character at the end
of the last line is because YOU PUT IT THERE.
x[0] = fgetc(fp);
The first time you try to read past the end of the file, fgetc returns
-1, which you coerce to (char)0xff and append that to the string. The
right way to do what you want is to add a check after the fgetc,
rather than (or, if you want to support Borland's buggy feof, in
addition to) after the strcat.
> Make sure the next release of DJGPP fixes this bug.
No. It's not a bug, and besides, you have no right to tell us what to
do. The only thing you have the right to do is fix it yourself if
it's that important to you.
- Raw text -