Pointer

Pointer

  • Pointer is a variable that contains the address of another variable.
  • A pointer can contain the address of any basic datatype, of array, structures, unions, etc.
  • Pointer contain address not values.

The two fundamental operators used with pointers are:

  1. The address operator(&)
  2. The Indirection operator(*)

The address operator(&):  The address operator returns the address of variable

x=10;
printf(“\n value of x=%d”,x);
printf(“\n Address of x =%d”, &x);

output:
value of x =10
Address of x =2002

The Indirection operator(*): The Indirection operator returns the value of the variable that the pointer is pointing to.

x=10;
printf(“\n value of x=%d”,x);
printf(“\n Address of x =%d”, &x);
printf(“\n value of Address of %d =%d”, &x, *(&x));

output:
value of x =10
Address of x =2002
value at address 2002=10