Pointer is a fundamental part of C.

Use of pointers gives the power and flexibility.
C uses pointers explicitly with
– Arrays,
– Structures,
– Functions.
C uses pointers a lot.
– It is the only way to express some computations.
– It produces compact and efficient code.
– It provides a very powerful tool.

What is a Pointer?

  • A pointer is a variable which contains the address in memory of another variable.
  • We can have a pointer to any variable type.
  • The operator & gives the address of a variable.
  • The indirection or dereference operator *gives the contents of an object pointed to by a pointer.
  • To declare a pointer to a variable do:

Int *pointer_var_name;
In the following example px is a pointer to objects of type float, and sets it equal to the address of x:

float x;
float *px;
x = 6.5;
px= &x;

* The content of the memory location referenced by a pointer is obtained using the ``*'' operator (this is called dereferencing the pointer).
* Thus, *px refers to the value of x.