answersLogoWhite

0


Best Answer

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.

User Avatar

Wiki User

9y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why would you use the array of pointers to pointers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

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.


What is an array pointers?

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


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.


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.


How do you store a string of letters for example abcdeabcde each to an array?

In C programming you would use the following: char a[] = "abcdeabcde"; If you wish to create an array with more than one string, use an array of character pointers instead: char* a[] = {"abcde", "fgh", "ijklm", "nopq", "rstu", "vwxyz"};


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.


How do you implement stack without array?

Stacks are often implemented using the same node structure as a linked list.


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"


How do you use bsearch function to search a name sorted in array of pointers to string?

solution of above question on (link moved to link section)


What is sparse array?

A sparse array (or sparse matrix) is an array where only a few elements are actually allocated storage space in memory, the unallocated elements are forced to zero for calculation purposes. Such arrays usually use pointers to reference the storage for the allocated elements.