C Pointers

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

Pointer Definition in C

type *variable_name;
int  *width;
char  *letter;

Benefits of using Pointers in C

  • Pointers allow 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


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

Scroll Back to Top