What is the meaning of double pointer (pointer to pointer) in C?

We already know that a pointer points to a location in memory and thus used to store the address of variables. So, when we define a pointer to 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.

How to declare a pointer to pointer in C?
Declaring Pointer to Pointer is similar to declaring pointer in C. The difference is we have to place an additional ‘*’ before the name of pointer.

In C programming language, a double pointer, also known as a pointer to pointer, is a pointer variable that stores the memory address of another pointer. It is used to represent the address of a pointer, which in turn points to the location where a value or an object is stored in memory.

To declare a double pointer in C, we use the syntax type **pointer_name. Here, type is the type of data that the pointer is going to point to, and pointer_name is the name of the double pointer variable.

Double pointers are commonly used in C to allocate and deallocate memory dynamically. They are especially useful when working with multidimensional arrays, structures, and linked lists.

One important thing to note is that the dereferencing operator (*) must be used twice to access the value that the double pointer is pointing to. For example, to access the value of an integer pointed to by a double pointer **p, we would use the expression **p.

Double pointers can be confusing and tricky to use, so it is important to have a good understanding of pointer concepts and memory management in C before working with them.

Submit Your Programming Assignment Details