Path: utzoo!utgpu!watserv1!watmath!att!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!samsung!uunet!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: problem with fread/fwrite Keywords: fread, fwrite, file pointers Message-ID: <4215@goanna.cs.rmit.oz.au> Date: 7 Nov 90 03:01:21 GMT References: <402@bally.Bally.COM> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 19 In article <402@bally.Bally.COM>, siva@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.