[Solved] Absurd output. Gives different output with and w/o debugging. Need expert intervention [duplicate]


Your construction invokes Undefined Behavior.

See Undefined behavior in c/c++: i++ + ++i vs ++i + i++ and Why are these constructs (using ++) undefined behavior?

 #include<iostream>

 using namespace std;
 int main()
 {
 int i=2;

 //cout<<i++<<i<<i++<<i; // UB! 

  cout<<i++; 
  cout<<i;
  cout<<i++;
  cout<<i;

  return 0;
}

1

solved Absurd output. Gives different output with and w/o debugging. Need expert intervention [duplicate]