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


Groups > comp.lang.c > #7262

Re: Determining EOF using fseek()?

From Eric Sosman <esosman@ieee-dot-org.invalid>
Newsgroups comp.lang.c
Subject Re: Determining EOF using fseek()?
Date 2011-06-29 21:51 -0400
Organization A noiseless patient Spider
Message-ID <iugksq$4ev$1@dont-email.me> (permalink)
References <iug5sl$5je$1@speranza.aioe.org>

Show all headers | View raw


On 6/29/2011 5:36 PM, Orion wrote:
> 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.

     "Traverse through the file from start to end" -- sounds like plain
sequential input operations like fread() and getc() would do the job
just fine.  From what you've said, I can't see a need for fseek().

> However, my loop
> doesn't seem to work well - it totally fumbles out actually:
>
> while ((a = fseek(fp,0,SEEK_CUR)) == 0){
>          // code here
>
> }

     The fseek() here looks a lot like a no-op: "Go to the position
zero bytes distant from the current position (i.e., go to Right Here),
and tell me if you couldn't get there."  What were you expecting it
to do?  And why?

> 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.

     What do you mean, "This is not the case?"  Did you get a non-
zero value from your no-op fseek()?  If so, what steps did you take
to determine that there was no error?

> Anyone with suggestions with using fseek() or some other function?
>
> Any help would be greatly appreciated! Thanks.

     I think you need to describe your intent better.  Exhibiting
one no-op fseek() call doesn't give us much to go on.

-- 
Eric Sosman
esosman@ieee-dot-org.invalid

Back to comp.lang.c | Previous | Next — Previous in thread | 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