, used in all three ads
int a = (1,2,3); int b = (++a, ++a, ++a); int c = (b++, b++, b++);
comma It evaluates the first operand 1 and discards it, then calculates the second operand and returns its value. Hence,
int a = ((1,2), 3); // a is initialized with 3. int b = ((++a, ++a), ++a); // b is initialized with 4+1+1 = 6. // a is 6 by the end of the statement int c = ((b++, b++), b++); // c is initialized with 6+1+1 = 8 // b is 9 by the end of the statement.
1 The evaluation order is guaranteed from left to right in the case of a comma.
source share