problem with fread/fwrite
Richard A. O'Keefe
ok at goanna.cs.rmit.oz.au
Wed Nov 7 14:01:21 AEST 1990
In article <402 at bally.Bally.COM>, siva at bally.Bally.COM (Siva Chelliah) writes:
> I do not remember reading
> anywhere that I should do a fseek before fread/ fwrite. Is that a bug in the
> compiler or in my head ? Please help.
It's in your head. Basically the model is that a stream can be in one
of three states:
undetermined
reading
writing
When you read from a stream, it should not be in 'writing' state.
When you write to a stream, it should not be in 'reading' state.
fseek() and rewind() put a stream back into 'undetermined' state.
This has been the case at least since V7 stdio, maybe longer.
Check your documentation again; it may be under "fopen" where the
meaning of r+ is explained.
--
The problem about real life is that moving one's knight to QB3
may always be replied to with a lob across the net. --Alasdair Macintyre.
More information about the Comp.lang.c
mailing list