this was where i got an error in nov cook off and wondered why it was giving an error in online compiler and not on codeblocks .
It’s not incorrect.
You do not need to ask “duplicate” question, you can ask in thread you referenced…
Good advice for a beginner is: “Do not use something, you do not understand fully”. And this is not related only to this operators…
According to my tests, it works on ideone (http://ideone.com/SDs3yR ), which online compiler you meant?
As mentioned on SO, it’s undefined, so it may work in one compiler, but not in another…
- Undefined behaviour.
- If you are getting the result, that also depends on compiler. In different compiler, u will get different result.
- Reason: A variable cannot be modified more than once in any expression unless the modification is punctuated with a sequence point.
- Don’t try to operate more than once upon a variable in a single expression.
- There are 6 in Sequence points in standard C++. A sequence point guarantees that all the side effects of the previous expression are complete and no side effects from sub-sequence expression have been performed. Since i is modified more than once and read in this expression, the result is undefined.
thanks for the advice and help.
thanks for a good explanation.