www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/30/03:31:49

Newsgroups: comp.os.msdos.djgpp
From: fredex AT fcshome DOT stoneham DOT ma DOT us (Fred Smith)
Subject: Re: problem with fseek and/or feof
X-Newsreader: TIN [version 1.2 PL2]
Organization: None!
Message-ID: <F37q0s.5uC@fcshome.stoneham.ma.us>
References: <36615BB8 DOT 7FCDE53F AT gmx DOT de>
Date: Mon, 30 Nov 1998 02:10:04 GMT
Lines: 22
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Christian Hofrichter (ChristianHofrichter AT gmx DOT de) wrote:
: I have a problem with "feof" and "fseek".

While it is not clearly documented (at least not in the man pages
I just checked) I think it is true that:

-feof only returns TRUE if the "eof flag" is set;
-the "eof flag" is not set by fseek
-the "eof flatg" IS set by one of the read functions (getchar, getc,
fgetc, gets, fgets, fread, etc) ONLY.

Therefore, what feof tells you is if the most recent **READ OPERATION**
has encountered EOF, not if the current **file position** is at EOF.
If you addd a getc() in your loop, right following the fseek() you'll
see the behavior you expect.

Fred
--
---- Fred Smith -- fredex AT fcshome DOT stoneham DOT ma DOT us -----------------------------
                         For the wages of sin is death, 
            but the gift of God is eternal life in Christ Jesus our Lord
------------------------------ Romans 6:23 (niv) ------------------------------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019