
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
C program to display relation between pointer to pointer
In C programming language, pointer to pointer or double pointer is a variable that holds the address of another pointer.
Declaration
Given below is the declaration for pointer to pointer −
datatype ** pointer_name;
For example, int **p;
Here, p is a pointer to pointer.
Initialization
‘&’ is used for initialization.
For example,
int a = 10; int *p; int **q; p = &a;
Accessing
Indirection operator (*) is used for accessing
Sample program
Following is the C program for double pointer −
#include<stdio.h> main ( ){ int a = 10; int *p; int **q; p = &a; q = &p; printf("a =%d ",a); printf(" a value through pointer = %d", *p); printf(" a value through pointer to pointer = %d", **q); }
Output
When the above program is executed, it produces the following result −
a=10 a value through pointer = 10 a value through pointer to pointer = 10
Example
Now, consider another C program which shows the relationship between pointer to pointer.
#include<stdio.h> void main(){ //Declaring variables and pointers// int a=10; int *p; p=&a; int **q; q=&p; //Printing required O/p// printf("Value of a is %d
",a);//10// printf("Address location of a is %d
",p);//address of a// printf("Value of p which is address location of a is %d
",*p);//10// printf("Address location of p is %d
",q);//address of p// printf("Value at address location q(which is address location of p) is %d
",*q);//address of a// printf("Value at address location p(which is address location of a) is %d
",**q);//10// }
Output
When the above program is executed, it produces the following result −
Value of a is 10 Address location of a is 6422036 Value of p which is address location of a is 10 Address location of p is 6422024 Value at address location q(which is address location of p) is 6422036 Value at address location p(which is address location of a) is 10
- Related Articles
- Double Pointer (Pointer to Pointer) in C
- Go Pointer to Pointer (Double Pointer)
- How to define pointer to pointer in C language?
- Explain the concept of pointer to pointer and void pointer in C language?
- Explain the concept of Array of Pointer and Pointer to Pointer in C programming
- How to assign a pointer to function using C program?
- Pointer to an Array in C
- Golang program to print pointer to a struct
- C++ Program to Access Elements of an Array Using Pointer
- C++ Program to count Vowels in a string using Pointer?
- Difference between pointer and array in C
- C/C++ Pointer Puzzle?
- Differentiate the NULL pointer with Void pointer in C language
- Function pointer to member function in C++
- To count Vowels in a string using Pointer in C++ Program

Advertisements