What's wrong with printf() , exit() ?
Larry Cipriani
lvc at danews.UUCP
Sun May 11 22:31:22 AEST 1986
> 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
More information about the Comp.lang.c
mailing list