Pointer to Pointer Program in C

Pointer to Pointer Program in C. The address of a value is stored in a pointer variable. The address of the pointer variable is stored in a pointer to a pointer. ** is used to execute a pointer to a pointer. A pointer is a variable whose value is the address of another variable that is the memory location’s direct address.

#include<stdio.h>
int main()
{
int var;
int *ptr;
int **pptr;
var = 10;
ptr = &var;
pptr = &ptr;
printf("\n\nValue of var = %d\n\n", var);
printf("\n\nValue available at *ptr = %d\n\n", *ptr);
printf("\n\nValue available at **pptr = %d\n\n", **pptr);
return 0;
}

 

Output:

Value of variable = 10

Value available at *ptr = 10

Value available at **pptr = 10

Pointer in C

A pointer is a variable whose value is the address of another variable, the memory location’s direct address. A pointer, like any variable or constant, must be declared before it can be used to store any variable address. 

A pointer is a variable that stores the address of a memory location. Pointers are used to keep track of the addresses of other variables or memory items. Pointers are extremely useful for another type of parameter passing known as Pass By Address.

Double Pointer in C

The first pointer is used to store the variable’s address. The address of the first pointer is stored in the second pointer. This is why they are also referred to as double pointers. 

In contrast, pointer to pointer means that a pointer stores the address of another pointer, and this second pointer stores the address of the previous or first pointer, which is also known as a double-pointer in C. As a result, when we want to store the address of the pointers, we use double pointers. Using this program we can execute pointer to pointer program in c

**p in C Program

In C, this means that **p is a double pointer. In C, a pointer is a special type of variable that stores the address of another variable as its value or points to the memory location of another variable. A double pointer is a pointer that contains the address of another pointer.