comma operator

michael.p.lindner mpl at cbnewsl.ATT.COM
Thu Aug 3 02:26:52 AEST 1989


In article <... (names hidden to protect the guilty)
> > dandb at k.gp.cs.cmu.edu (Dean Rubine) writes:
> > >I also occasionally use the comma to save braces:
> > >	if((f = fopen(file, "r")) == NULL)
> > >		fprintf(stderr, "Can't open %s\n", file), exit(2);
> 
> various erroneous discussions of how order of evaluation is wrong
> or that these are statements and can't be used as expressions.

***FLAME ON!***
Sigh.  RTFM!  The comma operator guarantees left to right evaluation,
and fprintf(...) and exit(...) ARE valid expressions in C.
sputter sputter - flame off.

Mike Lindner
attunix!mpl or mpl at attunix.att.com
AT&T Bell Laboratories
190 River Rd.
Summit, NJ 07901



More information about the Comp.lang.c mailing list