comma operator

David Rees reesd at gtephx.UUCP
Wed Aug 2 01:31:00 AEST 1989


> 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);

WOuldn't this cause problems based on the order of evaluation? I know
that the evalaution of the variables can be either left to right,
or right-to-left (depending on the machine). Does this mean that the
order of execution would also depend on the machine? Also by using
braces and semi-colons we know exactly what order things are going
to go in. Of course, it does save braces.

		-Dave



More information about the Comp.lang.c mailing list