Pointer is very interesting feature of C language. With the help of the pointers we can perform low level operations like memory management in C language which are impossible without pointers.

Pointers are the variables that stores memory address of another variable.

Features of Pointers in C

  1. It helps in the dynamic memory management.
  2. It stores the memory address of another variable.
  3. It provides a way to return more than one value to the function.
  4. Reduces the execution time of the program.
  5. Provides an alternative way to access array elements.

Declaration of pointer variable

To declare pointer variable is similar as declaring any other variable except we need to provide asterisk (*) symbol before the variable name.

type *variable_name;

Here type can be any data type and variable_name should be a valid identifier.

int *var;

float *myNumber;

char *ch;

Using pointers in program

To use pointer in a program we need to follow following steps:

  1. Declare the pointer variable
  2. Assign address of a variable to pointer variable
  3. Access the value that the pointer variable is pointing

Program example of pointers in C


int main()
    int var = 10;
    int *ptr;

    ptr =&var;

    printf("Actual variable = %d\n", var);
    printf("Address stored on pointer variable is %d\n", ptr);
    printf("value that the pointer pointing is %d\n", *ptr);
    return 0;


Actual variable = 10
Address stored on pointer variable is 0x7fff50ac0aa8
value that the pointer pointing is 10