This question already has an answer here:
- Why are these constructs using pre and post-increment undefined behavior? 14 answers
I ran a C program and got different output on different C compilers. Below is my program
void main()
{
int i=5;
printf("%d%d%d%d%d",i++,i--,++i,--i,i);
}
ON boarnland c++ complier o/p is
45545
and on gcc its
45555
is it really compiler dependent or its OS dependent?
The arguments in a function call are pushed into the stack from left to right. The evaluation is by popping out from the stack. and the evaluation is from right to left, hence the result.