increment and decrement on pointer

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



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

1.++c;

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

On the other hand,

2.c++;

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!