a[++y]=a[y]+1;

Write here if you have problems with your C++ source code

Moderator: Board moderators

CDiMa
Experienced poster
Posts: 214
Joined: Fri Oct 17, 2003 5:49 pm
Location: Genova

Post by CDiMa »

Farqaleet wrote:Following is what MSDN says
"In the prefix form, the increment or decrement takes place before the value is used in expression evaluation..."
By this the increment is done before y is used anywhere in the expression. That's what microsoft says. but then again you can't say anthing otherwise without checking other docs eg. Borland, gcc, g++ etc.
The problem doesn't lie in the value held by the pre/postfix operator, but the point in code where the side effect of the variable being changed takes place. So when you access again y to read its value before the next sequence point you don't know if y has already been in/decremented or not.

Ciao!!!

Claudio
Post Reply

Return to “C++”