Operations on Pointers in C Programming Language
In C Programming Language, the only operations that can be carried out on pointers are summarized below:
- A pointer variable can be assigned the address of an ordinary variable (e.g.,
pv = &v
) - A pointer variable can be assigned the value of another pointer variable (e.g.,
pv = px
) provided both the pointers point to objects of the same data-type - A pointer variable can be assigned a null (zero) value (e.g.,
pv =NULL
, where NULL is a symbolic constant that represents the value 0) - An integer quantity can be added to or subtracted from a pointer variable (e.g.,
pv + 3
,++pv
, etc.) - One pointer variable can be subtracted from another pointer variable provided both pointers point to elements of the same data-type
- Two pointer variables can be compared provided both the pointers point to objects of the same data-type
sum of two number using function pointer,
sum of two number using function pointer.