Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!rpi!batcomputer!munnari.oz.au!bruce!cechew From: cechew@bruce.cs.monash.OZ.AU (Earl Chew) Newsgroups: comp.lang.c Subject: Re: problem with fread/fwrite Keywords: fread, fwrite, file pointers Message-ID: <3369@bruce.cs.monash.OZ.AU> Date: 17 Nov 90 06:38:13 GMT References: <402@bally.Bally.COM> <14384@smoke.brl.mil> <13992@ulysses.att.com> <3337@bruce.cs.monash.OZ.AU> <880@jonlab.UUCP> Organization: Monash Uni. Computer Science, Australia Lines: 28 In <880@jonlab.UUCP> jon@jonlab.UUCP (Jon H. LaBadie) writes: >If in the stdio buffer I have the following; > Mary had a big sheep. Supercalifragalisticexpalidocious ... > ^ >With my pointer (read in this case) on the 'M', after I fread 23 bytes, >so my buffer and pointer are such: > Mary had a big sheep. Supercalifragalisticexpalidocious ... > ^ >what is wrong with fwrite'ing "Jack and Jill" on top of Super...? >I.e. what is critical returning to some ground zero state before >making a transition? With `traditional' stdio implementations, the FILE will still be in `READING' mode --- despite the fact that the fwrite() (or putc, etc) may `apparently' succeed. However, when the buffer is exhausted, you will find that no write(2) is performed (ie the fact that the buffer is dirty is not recorded) because of the `READING' mode, and you will lose the data you wrote. Earl -- Earl Chew, Dept of Computer Science, Monash University, Australia 3168 EMAIL: cechew@bruce.cs.monash.edu.au PHONE: 03 5655447 FAX: 03 5655146 ----------------------------------------------------------------------