Ternary conditional and assignment operator precedence
I'm confused about direct assignment and ternary conditional operators precedence: #include<stdio.h> int main(void) { int j, k; j = k = 0; (1 ? j : k) = 1; // first printf("%d %d\n", j, k); j = k = 0; 1 ? j : k = 1; // second printf("%d %d\n", j, k); return 0; } I would expect the output to be: 1 0 1 0 But it happens to be: 1 0 0 0 Plus I get this warning: main.cpp:20: warning: statement has no effect which is about the line I commented as second. Since the direct assignment operator has less precedence than the ternary conditional operator, I was expecting lines commented as first and second