I have seemingly very basic question about the order of operations in c, specifically involving the increment operator.
If I have this code:
int x,y;
y = 4;
x = ++y + y--;
printf("x: %d y: %d", x,y)
The output I expect is:
x: 10 y: 4
I got this using the process described here:
http://ntci.on.ca/compsci/java/ch2/2_3.html
(See Example 2, in the red box)
When I run this in eclipse on Mac with the MacOSX GCC, this is the answer it gives. Great.
However, when I use CLion (under MinGW), it gives:
x: 9 y: 4
So does Code::Blocks (with MinGW), and many online compilers such as:
https://www.onlinegdb.com/online_c_compiler
and
jdoodle's
and
tutorialspoint's.
What gives? Is eclipse and my understanding of the order of operations in C wrong?
Or are CLion, Code::Blocks, and a ton of online compilers wrong?