I have this C code line:
int a;
a = (1, 2, 3);
printf("%d", a);
Why the value 3
is printed? (the last one).
I have this C code line:
int a;
a = (1, 2, 3);
printf("%d", a);
Why the value 3
is printed? (the last one).
The comma operator evaluates all its "members" but returns the value of the last expression.
From the C11 standard:
The left operand of a comma operator is evaluated as a void expression; there is a sequence point between its evaluation and that of the right operand. Then the right operand is evaluated; the result has its type and value.