New course! Every coder should learn Generative AI!
Try a free lesson+ 1
In C++, the output starts from right or left ?
Int a=0; Cout<<a++<<++a<<a<<a++; //Output: 0222 or Output: 2210 ??
3 Answers
+ 7
Very interesting UB ¹!
The compilation log:
"warning: operation on 'a' may be undefined [-Wsequence-point]"
Reason:
"When modifying an object between two sequence points, reading the value of the object for any other purpose than determining the value to be stored is also undefined behavior."
_____
¹ https://en.wikipedia.org/wiki/Undefined_behavior#Examples_in_C_and_C++
+ 2
Felix Moelder, C++ Soldier (Babak) - Thanks for the information. 🙂
+ 1
From left to right