A pointer is a variable in C, and the pointers value is the address of a memory location.

Pointer Definition in C

Syntax:
type *variable_name;
Example:
int  *width;
char  *letter;

Benefits of using Pointers in C

  • Pointers allow the passing of arrays and strings to functions more efficiently.
  • Pointers make it possible to return more than one value from the function.
  • Pointers reduce the length and complexity of a program.
  • Pointers increase the processing speed.
  • Pointers save the memory.

How to Use Pointers in C

Example:
#include<stdio.h>

int main ()
{
   int  n = 20, *pntr;  //actual and pointer variable declaration

   pntr = &n;  //store address of n in pointer variable

   printf("Address of n variable: %x\n", &n  );

   //address stored in pointer variable
   printf("Address stored in pntr variable: %x\n", pntr );

   //access the value using the pointer
   printf("Value of *pntr variable: %d\n", *pntr );

   return 0;
}
Address of n variable: 2cb60f04

Address stored in pntr variable: 2cb60f04

Value of *pntr variable: 20