Explain the unexpected behaviour

Why this code has different output on different compilers?

int main() {
int x=5, y=5;
cout<<x--;
cout<<",";
cout<<--x;
cout<<",";
cout<<y--<<","<<--y;
return 0;
}



Output on Turbo C: 

5,3,4,4

Output on GCC:

5,3,4,3

Leave a Reply