From mboxrd@z Thu Jan 1 00:00:00 1970 Message-Id: <200104241803.TAA21877@localhost.localdomain> To: 9fans@cse.psu.edu Subject: Re: [9fans] the declaration of main() In-Reply-To: Your message of "Tue, 24 Apr 2001 11:32:07 BST." <20010424102506.0481119AA6@mail.cse.psu.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii From: Steve Kilbane Date: Tue, 24 Apr 2001 19:03:25 +0100 Topicbox-Message-UUID: 8e46d3bc-eac9-11e9-9e20-41e7f4b1d025 > gwyn@arl.army.mil wrote: > > forsyth@vitanuova.com wrote: > > > it's unfortunately more error prone than void/exit. for instance, it was > > > common to forget fflush() in the presence of setbuf/setvbuf in main for an auto buffer > > > and worse, that sometimes `worked' (until ported). > > > > I don't understand what you're talking about. > > consider: > > #include > int main(void) > { > char buf[100]; > setvbuf(stdout, buf, _IOFBF, sizeof(buf)); > printf("hello, world\n"); > return 0; > } Hold on. That's not a justification for the type of main(). It's Just Plain Bad. Saying that you wouldn't have a problem if you were forced to exit() instead is a bogus argument, because things would still go wrong if you forgot to call exit() (so you're exchanging one programming error for another), or if you had the buffer in a deeper scope, but called exit() as required. steve