Friday, 16 April 2010

Example program on pointer to pointer

#include <stdio.h>

int main (void)
{

  int a;
  int* pa = &a;
  int** pp = &pa;

  printf("\nPlease enter an integer value: ");
  scanf("%d",&a);

  printf("\nValue of variable a: %d", a);
  printf("\nAddress of variable a: %p", &a);
  printf("\nValue of pointer pa: %p", pa);
  printf("\nDe-referenced value of pointer pa: %d", *pa);
  printf("\nValue of pointer pp: %p", pp);
  printf("\nDe-referenced value of pointer pp: %d\n\n", **pp);

  return 0;

}

Pointers

No comments:

Post a Comment