PAGE2GO2 HOME | INTERNET NEWS

LeighExchange - Free Advertising Network Stock Research at Internet Speed

Re: fseek() clears EOF?

 List
Subject: Re: fseek() clears EOF?
Poster: EricSosmanesosman@acm-dot-org.invalid
Date: Fri, 23 Mar 2007 16:27:29 -0500
Related Postings: 1 2 3 4
wumei2010@googlemail.com wrote:
>> It clears the
>> stream's "I've hit the end of the file" indicator, which
>
> Here "clears" doesn't mean EOF is removed, right?

The end-of-file indicator is part of the stream, not part of the file. Again, I suggest you consider what changes are made to a read-only file when you fseek() a stream that's reading from it.


> i.e. it doesn't mean
> the stream could go beyond the actual end of the file.

Different file systems handle this differently, so C doesn't try to tell them all how to behave on an off-the-end fseek(). On some systems the fseek() will fail. On others, the fseek() may succeed but a subsequent attempt to read will fail. On yet others, it is possible to fseek() past the end of the file and start writing, producing a "sparse" file.

But none of these really has anything to do with "clearing the end-of-file indicator." That indicator reports the state of the stream, not of the file it's attached to.


> e.g. if the
> stream representing the original file is from memory location 0 to 10,
> when I fseek() from position 9, 3 locations, you will still get the
> EOF set for the stream right?9+3 is beyond the original stream
> representing the original file.

Here you've lost me: I don't understand how "memory locations" enter into the picture.

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

 

Page2Go2.com is not responsible for content of this message.