Pointer Arithmetic
We can manipulate the pointers too. We can perform operations such as addition, subtraction, increment and decrement etc.,. As the pointer variables have address, adding or subtracting a number results in another address, which is at an offset from the original address. This may be memory address occupied by another variable.
e.g.
int i, j, k ;
int *iptr = &i;
*iptr = *iptr + 2; // I = I + 2;
iptr = iptr + 2 // adds 2 to address.
These are useful when using arrays.
e.g.
arr[10];
int *iptrb = &arr[0];
int *iptre = &arr[10];
While ( iptrb != iptre)
{
Do something with the value if (*iptrb);
++iptrb;
}