Thursday, 4 August 2016

Pointer to Pointer

Pointer to Pointer


#include<stdio.h>
void main()
{
                int a = 5;
                int *p;
                int **q;
                p = &a;
                q = &p;

                printf("\n a = %d", a);
                printf("\n &a = %p", &a);

                printf("\n  p = %p",  p);
                printf("\n  *p = %d",  *p);
                printf("\n  &p = %p", &p);

                printf("\n q = %p", q);
                printf("\n  *q = %p", *q);
                printf("\n  **q = %d", **q);
                printf("\n &q = %p", &q);
}

Output:
 a            = 5
 &a         = 0028FF44

 p            = 0028FF44
 *p          = 5
 &p         = 0028FF40

 q            = 0028FF40
 *q          = 0028FF44
 **q        = 5
 &q         = 0028FF3C

No comments:

Post a Comment