C Programming Tutorial
Computer Tutorial

Pointer Operator



Pointer Operator

There are two pointer operators :
1. value at address operator ( * )
2. address of operator ( & )

1. Value at address operator ( * )

The * is a unary operator. It gives the value stored at a particular address. The ‘value at address’ operator is also called ‘indirection’ operator.
q = *m;
if m contains the memory address of the variable count, then preceding assignment statement can places the value of count into q.

2. Address of operator ( & )

The & is a unary operator that returns the memory address of its operand.
m = & count;
The preceding assignment statement can be “The memory address of the variable count is places into m”.

The following program that demonstrates the relationships between operators :

\* Pointer to initialize and print the value and address of variable. *\
# include < stdio.h >
int   main( )
{

int   a = 25  ;
int   *b  ;
b = &a  ;
printf("\n Address of a = %u ",   & a) ;
printf("\n Address of a = %u ",   b) ;
printf("\n Address of b = %u ",   & b) ;
printf("\n Value of b = %u ",   b) ;
printf("\n Value of a = %d ",   a) ;
printf("\n Value of a = %d ",   *( &a ) )) ;
printf("\n Value of a = %d ",   *b) ;
return ( 0 );

}

Output of the program :

Address of a = 12345
Address of a = 12345
Address of b = 12345
Value of b = 12345
Value of a = 5
Value of a = 5
Value of a = 5