+ 6

Pointer to pointer

What does it mean? any examples

6th Jan 2018, 2:54 PM
I'm_Groot
I'm_Groot - avatar
5 Answers
+ 10
A pointer which stores the address of another pointer. int x = 5; int* ptr = &x; int** ptr2ptr = &ptr; std::cout << *(*ptr2ptr);
6th Jan 2018, 2:59 PM
Hatsy Rei
Hatsy Rei - avatar
+ 9
int** array = new int*[size]; declares a pointer of type int*, and allocates a specified size of int* to it. You now have an array of int pointers.
6th Jan 2018, 3:06 PM
Hatsy Rei
Hatsy Rei - avatar
+ 4
can you explain me??please int** array = new int*[size]
6th Jan 2018, 3:03 PM
I'm_Groot
I'm_Groot - avatar
+ 1
include <iostream> using namespace std; int main () { int var; int *ptr; int **pptr; var = 3000; // take the address of var ptr = &var; // take the address of ptr using address of operator & pptr = &ptr; // take the value using pptr cout << "Value of var :" << var << endl; cout << "Value available at *ptr :" << *ptr << endl; cout << "Value available at **pptr :" << **pptr << endl; return 0; } When the above code is compiled and executed, it produces the following result − Value of var :3000 Value available at *ptr :3000 Value available at **pptr :3000
12th Feb 2022, 3:06 AM
Aditya Gautam
+ 1
A pointer to a pointer is a form of multiple indirection or a chain of pointers. Normally, a pointer contains the address of a variable. When we define a pointer to a pointer, the first pointer contains the address of the second pointer, which points to the location that contains the actual value.
12th Feb 2022, 3:07 AM
Aditya Gautam