Why does this code always produce x=2
?
unsigned int x = 0;
x++ || x++ || x++ || x++ || ........;
printf("%d\n",x);
the 1st x++
changes x to 1 and returns 0
the 2nd x++
changes x to 2 and returns 1
at which point the or short circuits, returns true, and leaves x at 2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With