From: utzoo!decvax!pur-ee!ecn-pa.scott
Newsgroups: net.unix-wizards
Title: Re: fseeks and stdio
Article-I.D.: ecn-pa.301
Posted: Thu Aug  5 08:51:11 1982
Received: Sun Aug  8 03:30:11 1982
References: sri-unix.2454

One B*I*G problem with stdio is that the count in the
iobuf structure means different things depending on
whether one is reading or writing.  I never remember
which is which, but in one of them, the count is the
the number of free bytes in the buffer, and in the
other the count is the number of bytes already used.
I.e. BOTH putc and getc decrement the count instead
of one incrementing and the other decrementing.  I
had an application in which I used the same structure
to hold some data, and turned it into a file if the
data exceeded the size of a buffer.  I ended up having
to write a kludge that turned a write buffer into a
read buffer.  So, yes, you do have problems if you're
both reading and writing a file and try to do fseeks.
The fseek can't really know where it is, because it has
no record of what was last done on the file.

	Scott Deerwester
	Purdue University Libraries