+ 4
New thing about sololearn compiler
It does not add 1 in variable if you write statement like that x=x++ in c++.While visual studio does add 1. Cannot say about other compilers. I have not used them. Hahahhaha It wasted quite my time.
8 Respuestas
+ 9
I know what you mean. its not a new thing, it has been around since forever.
+ 9
yeah its the same as saying x=x then going back after you already got your answer and saying oh i mean x=x+1 but not changing the answer.
The behaviour you see is actually quite logical when you think about it
+ 8
well it shouldnt. visual studio is probably correcting your mistake for you if it really works there as you state.
the reasoning behind this is as follows.
postfix assigns a value after the code is evaluated.
so when you state x = x++; the following happens.
assign the value from a copy of x into x, after this assignment add one to the value in the temp copy of x.
simply use x++; on its own both in visual studio and here and the behaviour will be as expected
+ 7
must autocorrect it for you when its compiled
+ 2
Ooky. I did not know that before. It surprised me a bit so I mentioned it.
+ 2
If its logical here than its not logical in visual studio by the way
+ 2
No,
Beacuse now I know it
+ 1
Bro I am stating that it does not increments here. The value remains same even in next line.Check it
U will be amazed