Preview
Pointer to pointer
A pointer variable in C language can also contain address of another pointer variable. This concepts is called pointer to pointer. We can declare a pointer to pointer as:
int **ptr;
Here, ptr is a pointer to pointer.
Program |
#include<stdio.h> int main() {int var1=20,*var2,**ptr;var2=&var1; ptr=&var2; printf(“\n*ptr=%u”,*ptr); return(0); |
Output |
*ptr=65524 **ptr=10 |
Description |
In the above program, ptr is pointer to pointer. It contains address of aother pointer variable var2 which contains the address of variable var1. *var2 refers to the value of var1. *ptr refers to the address of var1. **ptr refers to the value of variable var1. |
Best Books