Place your ad here
Pointers to Pointers in C
In the c programming language, we have pointers to store the address of variables of any datatype. A pointer variable can store the address of a normal variable. C programming language also provides a pointer variable to store the address of another pointer variable. This type of pointer variable is called a pointer to pointer variable. Sometimes we also call it a double pointer. We use the following syntax for creating pointer to pointer…
datatype **pointerName ;
Example Program
int **ptr ;
Here, ptr is an integer pointer variable that stores the address of another integer pointer variable but does not stores the normal integer variable address.
MOST IMPORTANT POINTS TO BE REMEMBERED
- To store the address of normal variable we use single pointer variable
- To store the address of single pointer variable we use double pointer variable
- To store the address of double pointer variable we use triple pointer variable
- Similarly the same for remaining pointer variables also…
Example Program
#include<stdio.h>
#include<conio.h>
int main()
{
int a ;
int *ptr1 ;
int **ptr2 ;
int ***ptr3 ;
ptr1 = &a ;
ptr2 = &ptr1 ;
ptr3 = &ptr2 ;
printf("\nAddress of normal variable 'a' = %u\n", ptr1) ;
printf("Address of pointer variable '*ptr1' = %u\n", ptr2) ;
printf("Address of pointer-to-pointer '**ptr2' = %u\n", ptr3) ;
return 0;
}
Output:
Place your ad here