From: utzoo!decvax!harpo!eagle!mhtsa!alice!rabbit!ark
Newsgroups: net.lang.c
Title: Re: read/write same file with one open -- Query
Article-I.D.: rabbit.1078
Posted: Thu Jan 27 17:48:50 1983
Received: Sun Jan 30 08:07:27 1983
References: burl.53

UNIX System III and, I believe, Berkeley UNIX allow a file to
be opened read/write.  You say:

	FILE *f;
	f = fopen("file", "r+");

(or "w+")  The + means that you can read and write.  WARNING:
If you have been reading and you want to write, or vice versa,
you must "switch modes."  This can be done by executing
lseek or rewind on the file.  Normally you will do one of these
anyway when changing.  (change lseek to fseek in the above line)
Note that fseek(f,0L,1) is a no-op, except that after you do it,
you can either read or write the file.