Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!harvard!caip!princeton!allegra!ulysses!burl!clyde!cbosgd!danews!lvc From: lvc@danews.UUCP (Larry Cipriani) Newsgroups: net.lang.c Subject: What's wrong with printf() , exit() ? Message-ID: <117@danews.UUCP> Date: Sun, 11-May-86 08:31:22 EDT Article-I.D.: danews.117 Posted: Sun May 11 08:31:22 1986 Date-Received: Mon, 19-May-86 01:53:59 EDT References: <501@brl-smoke.ARPA> <797@bentley.UUCP> Organization: AT&T Bell Labs, Columbus OH Lines: 31 > What's wrong with > printf("usage: foo bar\n"), exit(1); > as above? > Aside from style, exit is a statement syntatically but , requires expressions. The compilers I've used will accept this and do what you'd expect. Why is that ? Is this a special exeption ? Compilers may exist that won't accept it. However, this: printf("uage: foo bar\n"), return 1 ; generates a syntactic error message. If a compiler accepts , exit() why not , return ? Maybe it's too complicated to do, and not worth the trouble. Some uses of , are transparent and useful. Such as multiple initial- izations in a for loop, e.g. for(i = 0 , j = 1; ...). Doing all the relevant initializations in one place is important. Or in a while loop: while(readresp(CMD), command) where readresp is a void function (and has to be) and command is side affected several routines down. Coding this without the , obscures the code (at least to me). -- Larry Cipriani Nothing is worse than having danews!lvc an itch you can never scratch