int i=20; // i is equal to 20.
cout <<i<<" " <<i++<<" "<<i; // first it prints out i, which is 20.
//Then it prints out i++, which is i + 1. then it prints out i again with is 20.
If you thought that i++ permantently increases i then you're wrong. If you want to increase i. You do it like this
If you thought that i++ permantently increases i then you're wrong.
i++ does increase i.
The problem here is that the order of evaluation of function arguments is undefined, because you are modifying i and reading it in between sequence points.