Path: utzoo!mnetor!uunet!husc6!psuvax1!burdvax!sdcrdcf!trwrb!scgvaxd!stb!michael
From: michael@stb.UUCP (Michael)
Newsgroups: comp.lang.c
Subject: Re: closing stdout
Message-ID: <10008@stb.UUCP>
Date: 13 Dec 87 07:21:44 GMT
References: <442@cresswell.quintus.UUCP> <9658@mimsy.UUCP>
Reply-To: michael@stb.UUCP (Michael)
Organization: STB BBS, La, Ca, USA, 90402
Lines: 18
Keywords: Yes it IS a buggy library

In article <9658@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes:
>In fact, 4.3BSD stdio will allow this:
>
>	FILE *fp = fopen("foo", "r");
>	...
>	fprintf(fp, ...) ... fputs(..., fp) ... /* etc */
>	if (fflush(fp) || ferror(fp) || fclose(fp))
>		fprintf(stderr, "something went wrong\n");
>
>Everything works (with all the appropriate text appearing in file
>`foo') IF AND ONLY IF FILE foo DID NOT EXIST BEFORE THE fopen!  My

The fopen call is trying to open for reading an existing file. If the
file did not exist, it should FAIL, not just creat() it.
-- 
: Michael Gersten		ihnp4!hermix!ucla-an!remsit!stb!michael
:				sdcrdcf!trwrb!scgvaxd!stb!michael
: "Copy Protection? Just say 'Off site backup'. "