Pointer is one of the function In C
programming. The primary function of pointer is act as an address referrer of a
variable. The pointer obtain the value of a variable by referring its address.
The relationship between pointer and c-programming is similar to index and
book, the book contains everything but index can point out the item we are
looking for through refer to the page number.

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!

order now

Pointer also act as a simple and
accurate tunnel for program to allocate or refer the memory in memory location.
It acts similar to a personal secretary of a data or variable, because it has
the memory location and value of data.  However, it also can be used as an indicator
to display the value of the variable, while does not affect the variable
itself. A sample program and output will be provided in next section, further
explanation will be provided.

To declare a pointer, ‘*’ or asterisk
sign is used in pointer variable declaration.

An example of single line declaration
of pointer variable is shown as below.

Example 1:

int* a; //pointer declaration

Note: Since pointer variable is
address based, the pointer variable type is integer.


Next, ‘&’ or ampersand sign is
used to assign address location of an variable;

Example 2:

int b=5;

int*a=&b; //pointer a is
reference to the address of b

The lines above is showing that the
address of value of b, which is 5 has been assign to the pointer variable a.
Now, the pointer a is capable to fetch the memory location and value of b to
user. However, to obtain the value of b, dereference technique is used in the

To dereference a variable, which is
obtain the variable value of pointer holding, ‘*’ or asterisk sign is again
used in the line. However, the context of using asterisk sign in dereferencing is
slightly different than pointer declaration.

Example 3:

int b=5,c ;       // we are using new variable, c to dereference pointer


c=*a; // c is holding the value of b,
which is 5

Now variable c is holding the value
of b through using dereferencing method.


of program


int pointer (int a)  //function of pointer declaration


int*b = &a;

printf(“The value of x is %d

printf(“The address of x is %d

printf(“The address of pointer is %d”,&b);

return 0;


void main ()


int x =6;  //main variable, which
will be explained




In this program consists of
application of pointer which applying the address reference, dereferencing
method and isolate the main variable from pointer, so that the main variable
will not be affect by external environment.

The flow of the program goes like

Function “pointer” is declared, the
purpose of this function is use to declare pointer variable.

2.     In
main function, the main variable x is declared, value of 6 is assigned to it.

3.     Pointer
function is called, value of x is passed to it. The argument of function ‘a’.

4.     Pointer
variable b is declared and assigned memory location from local variable a.

There is three printf function, which point
to the value of main variable x, (dereference), memory location of x, and
address location of pointer itself respectively.

Hence the output of program shows
like this:


The value of x is 6

The address of x is 6422256

The address of pointer is 6422236


conclusion, the application of pointer can act as a reference to point to the
value of a main variable, which hold the memory location of the data
simultaneously. The translation of the data has higher efficiency in the
processor since it provide a guide or shortcut to point to the data.


Post Author: admin


I'm Irvin!

Would you like to get a custom essay? How about receiving a customized one?

Check it out