Sunday, June 1, 2008

Incremeting a pointer not working in C on casting

Question: Why incrementing a char pointer after casting it to a pointer to an int doesn't work in C?

Answer: Casting in C is a conversion operator and it returns a RValue, which can not be assigned to or incremented/decremented with ++/--. We can apply the ++/-- operators only on a LValue in C (i.e., on a variable) and not on a RValue (i.e., an evaluated value/constant).


1 comment:

Anonymous said...

I do trust all of the ideas you have offered for your post.
They're really convincing and will definitely work. Still, the posts are very short for starters. Could you please prolong them a bit from next time? Thank you for the post.
my web site :: my website