Originally posted by Valentin Crettaz:
i = i++;
the thing goes like this: first the value of i is stored in a register and then i is incremented, but the value used for the assignment is the old value of i stored in the register so the variable i (whose value is now 1) gets assigned the old value of 0, which is to say that i=i++; has no effect on the value of i. You are better off just doing i++;
HIH
According to Khalid Mughal, postfix operation is done before
assignment operation and also assignment operation has right
associativity i.e, right side expression is executed first.
Keeping all this in mind,
i = i++ ;
postfix operation should have been executed first and
since assignment operation is the last (in the order of precedance),i should have taken the value of 1.
Where am I wrong? Any help is greatly appreciated.
Thanks.
-Jay
[This message has been edited by Jay Kay (edited October 17, 2001).]