increment and decrement on pointer

This tip submitted by RAJKUMAR on 2011-08-03 00:31:45. It has been viewed 10298 times.
Rating of 5.0 with 21 votes

suppose a=10 and *c is an int variable and int pointer respectively, then


This statement will increment the value of variable a which is pointed by *c.

On the other hand,


This statement will increment by address not by pointed value, performing pointer arithmetic. Of course both of these are just a general case of dereferencing a pointer, but it's important to know that the * "takes effect" before the ++ does!

More tips

Help your fellow programmers! Add a tip!