It is obvious that first cout prints 7 7 but why the second one prints  8 8 7 ? Why not 7 8 8? How does such constructions work in c++?int ink(int *x){     *x += 1;     return *x;}int main(){    int *a;    int b = 6;    a = &b;    cout << ++b <<   << b << endl;       cout << b <<   << ink(a) <<   << b;    return 0;}
Order of executions in C++ streams
c++
Because the code contains side effects. You can't be sure in what order the elements will be executed.Here is some more info:http://en.wikipedia.org/wiki/Sequence_pointEDIT: Here is the output on my machine:7 68 8 7As you can see it's different from yours. The correct approach is to make all calculations before the cout and then pass the values only.