double pointer

I am not clear about creting arrays of arrays using double pointer.
can any one explain it......

I want so data on double poinets can u please give me some useful links
1
2
3
4
5
6
7
//Create your pointer
int **ptr;
//Assign first dimension
ptr = new int*[5];
//Assign second dimension
for(int i = 0; i < 5; i++)
	ptr[i] = new int[5];


The number of * kinda tell you how many pointers deep you are going. *ptf is a pointer to a data member, **ptr is a pointer to a pointer, and ***ptr is a pointer to a pointer to a pointer. Allocating space for the arrays is pretty easy, as seen above. That is an example of a dynamic 2d array. I could give an example of a 3d array if you want.
yeah sure
if any one has useful data on double pointers please share..
Tristanm is correct.

int** is a pointer to an int*.

And int* is a pointer to an int.

There are various applications. For example, if you wanted to pass a pointer by reference, one way is the double pointer.

1
2
3
4
5
6
7
8
9
10
11
void clear(int **p)
{
    *p = 0;
}

int main()
{
    int* p;
    clear(&p);
    return 0;
}


The example above uses double pointers to implement a 2D array.
Topic archived. No new replies allowed.