Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #7249

Determining EOF using fseek()?

From Orion <won@bigpond.net.au>
Newsgroups comp.lang.c
Subject Determining EOF using fseek()?
Date 2011-06-29 21:36 +0000
Organization Aioe.org NNTP Server
Message-ID <iug5sl$5je$1@speranza.aioe.org> (permalink)

Show all headers | View raw


Hey,

I was wondering if it was possible to determine if you hit 'EOF' using
fseek? I'm using fseek to traverse through the file from start to end
and capturing the data into a linked list structure. However, my loop
doesn't seem to work well - it totally fumbles out actually:

while ((a = fseek(fp,0,SEEK_CUR)) == 0){
        // code here

}

Its quite important for me not to disrupt the current position of the
cursor since I rely on that to fetch the data from the text file. I
thought that the loop would work fine since fseek only returns a
non-zero integer on an error but unfortunately this is not the case.
Anyone with suggestions with using fseek() or some other function?

Any help would be greatly appreciated! Thanks.

Back to comp.lang.c | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Determining EOF using fseek()? Orion <won@bigpond.net.au> - 2011-06-29 21:36 +0000
  Re: Determining EOF using fseek()? John Gordon <gordon@panix.com> - 2011-06-29 21:46 +0000
  Re: Determining EOF using fseek()? Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-06-29 21:51 -0400
    Re: Determining EOF using fseek()? John Gordon <gordon@panix.com> - 2011-06-30 03:55 +0000
  Re: Determining EOF using fseek()? David Thompson <dave.thompson2@verizon.net> - 2011-07-11 00:26 -0400
  Re: Determining EOF using fseek()? Squeamizh <squeamz@hotmail.com> - 2011-07-10 23:40 -0700
    Re: Determining EOF using fseek()? Uno <merrilljensen@q.com> - 2011-07-16 23:21 -0700

csiph-web