C Programming accessing value and address of Pointer



In this tutorial we will be learning the way for accessing value and address of Pointer. We can access the value of pointer using the de-reference operator and address of variable can be printed using address operator

Program : accessing value and address of Pointer

#include<stdio.h>
main() {
   int i = 3, *j, **k;
   j = &i;
   k = &j;
   
   printf("\nAddress of i = %u", &i);
   printf("\nAddress of i = %u", j);
   printf("\nAddress of i = %u", *k);
   printf("\nAddress of j = %u", &j);
   printf("\nAddress of j = %u", k);
   printf("\nAddress of k = %u", &k);
   printf("\nValue of j   = %u", j);
   printf("\nValue of k   = %u", k);
   printf("\nValue of i   = %d", i);
   printf("\nValue of i   = %d", *(&i));
   printf("\nValue of i   = %d", *j);
   printf("\nValue of i   = %d", **k);
}

Output :

Address of i = 65524
Address of i = 65524
Address of i = 65524
Address of j = 65522
Address of j = 65522
Address of k = 65520
Value of   j = 65524
Value of   k = 65522
Value of   i = 3
Value of   i = 3
Value of   i = 3
Value of   i = 3

Explanation

C Programming accessing value & address of Pointer

Consider the above diagram for accessing value and address of Pointer, It clear shows –

Variable Actual Value
Value of i 3
Value of j 65524
Value of k 65522
Address of i 65524
Address of j 65522
Address of k 65520