TECHGRAVE

Monday, April 17, 2006

Why i++ ++ won't work in C?

Why i++ ++ won't work in C? [Also ++i++ etc. will not work]

i++ yeilds a value, and operators don't work on values, they work on objects.
So the second ++ fails, with the error 'lvalue required' ie,address required.
Same is the case with ++i++.
To enumerate i++ is equivalent of(i = i + 1)
Correct ?
So an i++ ++ would be (i = i + 1) = ???That is the expression returns a value and not a variable and so thesecond operand can work on a value type for the simple reason thatsaying 5++ or 10++ is invalid.

0 Comments:

Post a Comment

<< Home