Comma Operator

nair at quintus nair at quintus
Sat Jan 14 12:37:47 AEST 1989


What should this print?

	int x, y;
	printf("%d %d\n", (x = 1, y = 2), x, y);

Shouldn't it be equivalent to:

	int a, x, y;
	a = (x = 1, y = 2);
	printf("%d %d %d\n", a, x, y);

Is there any justification in the first one printing
	2 1 0

Is there God? Why am I here? :-) :-)

Anil Nair

Please reply to nair at quintus.uucp or ...!sun!quintus!nair



More information about the Comp.lang.c mailing list