answersLogoWhite

0


Best Answer

A pointer is a variable that stores value of address of a variable. Since a pointer itself is a variable, it is allocated a memory location.

Pointer to pointer means a pointer which points to the address of a pointer. In other words a pointer to a pointer has the address of the address of a variable.


We can have pointers to int, and pointers to char, and pointers to any structures we've defined, and in fact pointers to any type in C, it shouldn't come as too much of a surprise that we can have pointers to other pointers. If we're used to thinking about simple pointers, and to keeping clear in our minds the distinction between the pointer itself and what it points to, we should be able to think about pointers to pointers, too, although we'll now have to distinguish between the pointer, what it points to, and what the pointer that it points to points.

User Avatar

Wiki User

7y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

16y ago

A pointer to pointer variable can hold the address of another pointer variable. The Syntax is as follow: type** variable; Example:: //function prototype void func(int** ppInt); int main() { int nvar=2; int* pvar=&nvar; func(&pvar); .... return 0; }


One more important use of pointer-to-pointer is for creating multi-dimensional array dynamically, see See the related links.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

A pointer points to another pointer in the same way that a pointer points to a non-pointer object.

Start with a pointer to an object...

int a; // the object

int *pa = &a; // the pointer

pa; // is the value of the pointer

*pa; // is the value of the object

Now, create a pointer to a pointer to an object

int a; // the object

int *pa = &a; // the first pointer

int **paa = pa; // the second pointer

a; // is the value of the object

pa; // is the value of the first pointer

*pa; // is the value of the object using the first pointer

*paa; // is the value of the second pointer

**paa; // is the value of the object using the second pointer

And so on and so forth... Just don't forget to initialize each pointer along the way!

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Perhaps an example will help:

struct demo {

int f1;

long f2;

} d1, *dptr;

dptr = &d1; /* now dptr is a pointer to the structured variable d1, which is of type 'struct demo' */

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

line

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is an array of pointers to pointers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is Arrays of Pointers?

An array of pointers is a contiguous block of memory that contains pointers to other memory locations. They essentially allow non-contiguous memory locations to be treated as if they were an actual array.


Why array is a implicit pointer?

An array of pointers is exactly what it sounds like - one or more pointers arranged in order in memory, accessible through a common base name and indexed as needed. Philosophically, there is no difference between an array of pointers and an array of objects...int a[10]; // 10 integers, named a[0], a[1], a[2], ..., a[9]int *b[10]; // 10 pointers to int, named b[0], b[1], b[2], ..., b[9]If you initialize the array of pointers...int i;for (i = 0; i < 10; i++) b[i] = &a[i];... then *b[0] would be the same as a[0], etc.


Why would you use the array of pointers to pointers?

You would use an array of pointers to pointers whenever you wished to implement a dynamic multi-dimensional array of 3 or more dimensions. Every multi-dimensional array can ultimately be reduced to a one-dimensional array where each element is itself a one-dimensional array (an array of arrays). With fixed-size arrays, all elements can be allocated contiguously regardless of how many dimensions there are. Fixed size arrays can be allocated both statically (when the size is known at compile time) or dynamically (when the size is unknown at compile time). However with large arrays it is often necessary to divide the array into smaller subarrays each of which is allocated separately (non-contiguously with each other) and maintain a separate array of pointers to keep track of each of those subarrays. Although this consumes more memory than a contiguously-allocated array would, it has the added benefit in that each subarray need not be the same length, thus it can actually save memory overall. However, if we had several such arrays then we would need yet another array in order to keep track of them all, and this array would need to be an array of pointers to pointers.


Pointer to 3 dimensons array?

If the array is static you can simply point at the first element. For dynamic arrays you can allocate a contiguous block to a single pointer which can then be subdivided using a one-dimensional array of pointer to pointers, each of which points to a one-dimensional array of pointers, each of which points to a separate object within the array. For extremely large arrays, however, it is better to split the elements into separate one-dimensional arrays, by creating a one-dimensional array of pointer to pointers first, then allocating each of those pointers to a separate one-dimensional array of pointers, each of which points to a separate one-dimensional array of objects. Either way, you must destroy all the individual arrays in the reverse order of creation.


What are the array operations?

There are no array operations in C. Arrays implicitly convert to pointers, thus any operation you might attempt upon an array you would actually perform on a pointer.

Related questions

What is an array pointers?

I guess it is an 'array of pointers'. Example:int main (int argc, char *argv[])


What is Arrays of Pointers?

An array of pointers is a contiguous block of memory that contains pointers to other memory locations. They essentially allow non-contiguous memory locations to be treated as if they were an actual array.


Why array is a implicit pointer?

An array of pointers is exactly what it sounds like - one or more pointers arranged in order in memory, accessible through a common base name and indexed as needed. Philosophically, there is no difference between an array of pointers and an array of objects...int a[10]; // 10 integers, named a[0], a[1], a[2], ..., a[9]int *b[10]; // 10 pointers to int, named b[0], b[1], b[2], ..., b[9]If you initialize the array of pointers...int i;for (i = 0; i < 10; i++) b[i] = &a[i];... then *b[0] would be the same as a[0], etc.


Why would you use the array of pointers to pointers?

You would use an array of pointers to pointers whenever you wished to implement a dynamic multi-dimensional array of 3 or more dimensions. Every multi-dimensional array can ultimately be reduced to a one-dimensional array where each element is itself a one-dimensional array (an array of arrays). With fixed-size arrays, all elements can be allocated contiguously regardless of how many dimensions there are. Fixed size arrays can be allocated both statically (when the size is known at compile time) or dynamically (when the size is unknown at compile time). However with large arrays it is often necessary to divide the array into smaller subarrays each of which is allocated separately (non-contiguously with each other) and maintain a separate array of pointers to keep track of each of those subarrays. Although this consumes more memory than a contiguously-allocated array would, it has the added benefit in that each subarray need not be the same length, thus it can actually save memory overall. However, if we had several such arrays then we would need yet another array in order to keep track of them all, and this array would need to be an array of pointers to pointers.


Pointer to 3 dimensons array?

If the array is static you can simply point at the first element. For dynamic arrays you can allocate a contiguous block to a single pointer which can then be subdivided using a one-dimensional array of pointer to pointers, each of which points to a one-dimensional array of pointers, each of which points to a separate object within the array. For extremely large arrays, however, it is better to split the elements into separate one-dimensional arrays, by creating a one-dimensional array of pointer to pointers first, then allocating each of those pointers to a separate one-dimensional array of pointers, each of which points to a separate one-dimensional array of objects. Either way, you must destroy all the individual arrays in the reverse order of creation.


How do you declare an array of five pointers to chars?

char *p="ragav"


What are array of string pointers?

An array of pointers to string would contain, per array position, a number dictating which memory address holds the string data. For example, position [0] in an array would contain a memory address. This memory address can be de-referenced to obtain the actual information held within that memory address.


What are the array operations?

There are no array operations in C. Arrays implicitly convert to pointers, thus any operation you might attempt upon an array you would actually perform on a pointer.


Array of pointers?

a pointer is a variable that contains memory location of another variable.the value u assign to the pointers are memory address of other variable.


What will be the program to arrange numbers stored in array in ascending order using pointers?

sorry


What is a character array?

A character array is list of pointers that point to characters. The way to use an array would depend on the language. Most arrays are 0 indexed meaning they begin at 0.


Is it possibly to return an array of strings in a function without using pointers in C plus plus?

No.