General form of a pointer declaration, Pointer arithmetic, Comparison of pointers, pointer arrays

General form of a pointer declaration:

type *name;

Pointers and arithmetic: Pointer arithmetic is very limited. You can do only few tasks with pointers:

1) Increment and decrement: For example: p++; and p–;

2) Addition and subtraction with integer: For Example: p = p-10;

All other arithmetic like multiplication, divisions, etc. is not allowed with pointers.

Comparison of pointers: Pointers can be compared, like:

If (p < q) printf (“More Process\n”);

Arrays of pointers: We can make an array of pointers. For Example:

int *a [5];

Address to an integer variable x to second element of pointer array can be assigned as:

a[1] = &x;

To find value of x: *a[1]

Leave a Reply