Pointer to Pointer or Double Pointer Example Program In C
Definition
- Pointer to Pointer locates/store to another pointer variable address.
- The dereference operator or indirection operator, noted by an asterisk ("*"), is also a unary operator in c languages that uses for pointer variables.
- Double Pointer or Pointer to Pointer need to place a ** before the name of the double pointer.
Syntax
data_type **pointer_variable;
Pointer to Pointer or Double Pointer Example Program
/*##Pointer to Pointer or Double Pointer Example Program with Reference operator (&) and Double Dereference operator (**)*/
/*##Simple Pointer Programs,Pointer to Pointer,Double Pointer*/
#include <stdio.h>
int main() {
int var;
//Pointer Variable Declaration for Integer Data Type
int *pt;
//Double Pointer Variable Declaration with Double Dereference operator (**)
int **dp;
var = 100;
printf("Address of var [&var ] :%p\n", &var);
printf("Value of var [var ] :%d\n\n", var);
//& takes the address of var , Here now pt == &var, so *pt == var
pt = &var;
printf("Address of Pointer [pt ] :%p\n", pt);
printf("Value of Pointer [*pt ] :%d\n\n", *pt);
//& takes the address of pt , Here now dp == &pt, so *pt == pt and **dp==var
dp = &pt;
printf("Address of Double Pointer [dp ] :%p\n", dp);
printf("Value of Double Pointer [*dp ] :%p\n\n", *dp);
printf("Double Pointer Value [**dp] :%d\n", **dp);
return 0;
}
Sample Output
Address of var [&var ] :0060FF08
Value of var [var ] :100
Address of Pointer [pt ] :0060FF08
Value of Pointer [*pt ] :100
Address of Double Pointer [dp ] :0060FF04
Value of Double Pointer [*dp ] :0060FF08
Double Pointer Value [**dp] :100
C Pointer Example Programs
- Simple Pointer Example Program
- Simple Program for Print address of Variable Using Pointer in C
- Pointer Simple Example Program with Reference operator (&) and Dereference operator (*)
- Simple Example Program for Swap Numbers Using Pointers In C
- Print size of different types Using Pointer in C
- Simple Program for Add Two Numbers Using Pointer in C
- Simple Program for Increment and Decrement Integer Using Pointer in C
- Simple Program for Increment and Decrement Floating Point Using Pointer in C
- Simple Program for Find a difference between two Numbers Using Pointer in C
- Simple Program for Change the value of constant integer Using Pointer in C
- Simple Program for Print String Using Pointer in C
- Simple Program for Count vowels String Using Pointer in C
- Simple Program for Length of String Using Pointer In C
- Pointer to Pointer or Double Pointer Example Program In C
- Simple Program for Pointer and Array Example in C
- Simple Program for Sum of Integer an array using pointers in C
- Simple Program for Read, Print and Sum of Integer in an array using pointers in C
- Simple Example Program for Passing pointers to functions In C
- Simple Example Program for Area Of Circle Using Pointer In C
Read More Articles
- Use of getch(),getche() and getchar() in C
- Switch Case Statement Example Program In C Programming Language
- C Character Set
- Convert a Floating-point value to an Integer in C
- Data Input and Output gets and puts Example Program In C
- Special Operators In C
- Pointer Representation and Pointer Example Programs
- C Data Input and Data Output
- Simple While Loop Example Program In C Programming Language
- Data Output printf and putchar Example Program In C
- C Introduction
- C Operators
- Storage Classes In C
- C Pointers
- File Management
- C Identifiers
- Loop Control Statements
- Hello World - Simple C Program
- C Array
- Single Character Output Function : putchar()
- C Reserve Words
- C Specific Properties and Implementation
- If else Statement Example Program In C Programming Language
- If Statement Example Program In C Programming Language
- Confusing Array in C ( Array Representation and Initialization )