Turbo C and ^Z's

Karl Heuer karl at ima.isc.com
Sat Jan 5 04:39:03 AEST 1991


In <OTTO.91Jan4115449 at tukki.jyu.fi> otto at tukki.jyu.fi (Otto J. Makela) writes:
>In <10251 at hydra.Helsinki.FI> wirzeniu at cs.Helsinki.FI (Lars Wirzenius) writes:
>>"a" means that all writes happen at the end of the file, use "r+b" instead.
>
>ALL WRITES ?  Come on, the first thing I do after that is to seek the file...

Lars is correct.  On a file opened in append-mode, fseek() is only useful for
reading.  (Though some historical implementations implemented append-mode with
an initial seek-to-end only, this is not acceptable in ANSI C.)

>I'd like to point out I can't use "r+b", 'cause it'll fail if the file does
>not exist beforehand.

Then use "w+b".

Karl W. Z. Heuer (karl at ima.isc.com or uunet!ima!karl), The Walking Lint



More information about the Comp.lang.c mailing list