Pointer is
derived data type in C. Pointer contain memory address as there value. Since these
memory address are the location in the Computer memory where program
instruction and data our Store.
Pointer variable is used to hold memory
address. This address is the location of the another variable where it have been store in the memory.
In other
words we can say that pointer is a
variable which hold the address of another variable is declared as first
variable pointing to the second variable.
Operator used with pointer:-
there are two basic operators used with pointers.
a) Address Pointer (&):-
the address pointer give
the address of variable.
b) Indirection Operator: -
Indirection operator
gives the value of the variable that the pointer is pointing to variable of program.
Ex.- int *p;
int q;
r = &q;
pointer arithmetic: -
the pointer arithmetic refers to
the use of the pointer with variable arithmetic operators. In C pointers can be
used along with arithmetic operation like addition, subtraction, increment or
decrement.
Pointers and functions:-
pointers are mainly used alone with function for
passing the address of the argument generally an argument can be passed onto
the function in two ways.
(i) call by Value
(ii) call by reference
1- call by Value:-
Call by Value refer to sending value or argument on to
the function. In this method the value of actually argument is copied on to the
corresponding format argument whenever a function is called the various
operation performed wonder effect on the wedding actual argument in the main()
function.
2- call by reference: -
Call by reference is a method
used to accept any function through the main program using pointers.
Using this
method the operation performed affect the value of actual argument. This age
because the argument contain the address of actual argument so any change on
that address affect the value.