I just compiled the program below in Cyqwin and on codepad
int main()
{
int k=1;
printf("%d, %d, %d\n", k, k++, k++);
}
In both cases the output was
3, 2, 1
Shouldn't it be the other way around?
Any thoughts would be welcome.
:)
Printable View
I just compiled the program below in Cyqwin and on codepad
int main()
{
int k=1;
printf("%d, %d, %d\n", k, k++, k++);
}
In both cases the output was
3, 2, 1
Shouldn't it be the other way around?
Any thoughts would be welcome.
:)
Read my answer here -> Comma Operator - C And C++ | Dream.In.Code
Then understand that the code has undefined behaviour.