Mail Archives: djgpp/2000/05/11/02:13:02
At 09:27 AM 5/11/00 +0400, you wrote:
>I think the Borland C compiler you use has a bit buggy LIBC.
>
>In fact, you must try to read one character from the file in order to
>determinde EOF. Just read help from BC:
>--------------------8<-----------------------
>Return Value:
> _ Returns non-zero if an end-of-file
> indicator was detected on the last input
> operation on the named stream.
> _ Returns 0 if end-of-file has not been
> reached.
>--------------------8<-----------------------
>
>*Last input operation* means you must invoke feof() after fgetc() or
>something like that.
>
>Btw, you may forget about feof() almost at all if you use fgetc(). That's
>because fgetc() returns an integer value (not a single-byte character). And
>the return value is -1 when you try to read past the end of the file.
>
>Good Luck
>Alexei A. Frounze
>-----------------------------------------
>Homepage: http://alexfru.chat.ru
>Mirror: http://members.xoom.com/alexfru
Actually, I have tested this code with both Borland's Turbo C v3.0 for DOS
as well as the latest Borland C++ Builder free command-line tools. The
exact same results tell be that over many generations of compilers (with
thousands and thousands of builds of the libraries and executables), either
Borland hasn't noticed a non-ANSI standard with feof, or they are following
the standard. My aim is to prove which one doesn't follow the ANSI
standard: gcc and all ports of it, or Borland.
So, to begin my proof, I went onto the manpages for Linux (on feof) and
discovered that the manpages claim to be following the specifications in
"C3.159-1989" I have searched both ANSI.org and NSSN.org as well as
regular web search engines for this particular document. However, I am
unable to find this document or anything newer. The only thing that kept
coming up was listings of online manpages that made the same reference to
this document that I can't find. If anyone can point me to this document
online (or even offline), I would greatly appreciate it.
Thomas J. Hruska -- shinelight AT crosswinds DOT net
Shining Light Productions -- "Meeting the needs of fellow programmers"
http://www.shininglightpro.com/
- Raw text -