How Double Pointer Works?
The working of the double-pointer can be explained using the above image:
- The double pointer is declared using the syntax shown above.
- After that, we store the address of another pointer as the value of this new double pointer.
- Now, if we want to manipulate or dereference to any of its levels, we have to use Asterisk ( * ) operator the number of times down the level we want to go.
C – Pointer to Pointer (Double Pointer)
Prerequisite: Pointers in C
The pointer to a pointer in C is used when we want to store the address of another pointer. The first pointer is used to store the address of the variable. And the second pointer is used to store the address of the first pointer. That is why they are also known as double-pointers. We can use a pointer to a pointer to change the values of normal pointers or create a variable-sized 2-D array. A double pointer occupies the same amount of space in the memory stack as a normal pointer.