posted 20 years ago
it is evaluated how you think. but the problem is (probably) in how you're thinking of the
x = x++;
note we are using the post-fix version. so, what happens is, the compiler says ok, i need to evaluate the right, THEN increment x. so, the rhs evaluates to 0. now increment x. so, x is now 1. NOW i need to assign the value of the RHS to x. the value was 0. so, assign 0 to x.
so, we end up printint out 0.
if you change it to ++x, you'll get 1.
[ August 26, 2004: Message edited by: fred rosenberger ]
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors