Comma Operator

Doug Gwyn gwyn at smoke.BRL.MIL
Sat Jan 14 22:33:24 AEST 1989


In article <922 at quintus.UUCP> nair at quintus () writes:
>What should this print?
>	printf("%d %d\n", (x = 1, y = 2), x, y);

"Warning -- missing format specifier for one argument".

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

[Assuming the format spec was fixed.]
The order in which arguments to functions are evaluated is intentionally
unspecified.  Some implementations do it one way, some another.  In your
case it appears that they were evaluated right-to-left.



More information about the Comp.lang.c mailing list