Search Your Topic

Tuesday, 13 June 2017 11:37

C Pointer to Pointer

Written by
Rate this item
(0 votes)

In C pointer to pointer concept, a pointer refers to the address of another pointer.

In c language, a pointer can point to the address of another pointer which points to the address of a value. Let's understand it by the diagram given below:

pointer to pointer in c

Let's see the syntax of pointer to pointer.

  1. int **p2;  

C pointer to pointer example

Let's see an example where one pointer points to the address of another pointer.

C pointer to pointer example

As you can see in the above figure, p2 contains the address of p (fff2) and p contains the address of number variable (fff4).

  1. #include <stdio.h>        
  2. #include <conio.h>      
  3. void main(){        
  4. int number=50;    
  5. int *p;//pointer to int  
  6. int **p2;//pointer to pointer      
  7. clrscr();    
  8. p=&number;//stores the address of number variable    
  9. p2=&p;  
  11. printf("Address of number variable is %x \n",&number);    
  12. printf("Address of p variable is %x \n",p);    
  13. printf("Value of *p variable is %d \n",*p);    
  14. printf("Address of p2 variable is %x \n",p2);    
  15. printf("Value of **p2 variable is %d \n",**p);    
  17. getch();        
  18. }        


Address of number variable is fff4
Address of p variable is fff4
Value of *p variable is 50
Address of p2 variable is fff2
Value of **p variable is 50


Read 6020 times
Anish Sir

"I am delighted once again to pen the welcome note to the Tosh!Yas Technologies ."

 Call +91 74 88 34 7779  | Email :
More in this category: « C Pointers Pointer Arithmetic in C »

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.