answersLogoWhite

0

What is Arrays of Pointers?

Updated: 12/9/2022
User Avatar

Wiki User

13y ago

Best Answer

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.

User Avatar

Wiki User

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

Wiki User

13y ago

A hard question to answer. If you do not understand the concept of array and the concept of pointer nothing I can tell you will be meaningful.

Learn about arrays and pointers and the answer will be self evident.

This answer is:
User Avatar

Add your answer:

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

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.


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.


What is the use of arrays over pointers?

Arrays can be regarded as constant pointers. Example: int *pi, ai[5]; pi= ai; /* okay */ pi[0]= ai[0]; /* okay */ ai[0]= pi[0]; /* okay */ pi= (int *)malloc (10*sizeof (int)); /* okay */ ai= pi; /* NOT okay */ ai= (int *)malloc (10*sizeof (int)); /* NOT okay */


How do you handle object array?

Exactly as you would any other type of array. An object's size is determined in the same way a structure's size is determined, by the sum total size of its member variables, plus any padding incurred by alignment. However, you cannot create arrays of base classes. Arrays of objects can only be created when the class of object is final; a class that has a private default constructor, otherwise known as a "leaf" class. This is because derived classes can vary in size; array elements must all be the same size. To create an array of base classes you must create an array of pointers to those base classes instead. Pointers are always the same size (4 bytes on a 32-bit system). Static arrays are ideally suited to arrays of leaf objects where the number of objects never changes, or the maximum number of objects is finite and fixed. Although you can use dynamic arrays of leaf objects, you will incur a performance penalty every time the array needs to be resized, because every object's copy constructor must be called during the reallocation. Dynamic arrays are better suited to arrays of pointers to objects -- only the pointers need to be copied during resizing, not the objects they point to.


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 are the data type in c language?

Some of them are: 1. char, short, int, long, float, double 2. pointers to these 3. arrays of these 4. arrays of pointers 5. pointers to arrays ...


How are pointers used to access arrays?

nbejhewb kukbn oniiu nir8g bewgu


Character arrays using pointers notes?

i don't know ask someone else


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.


Do you have pointer concept in c plus plus language?

Yes. All string variables are pointers as are other arrays.


What are the basic parts of the c language?

That would include header files, data types, loops, functions, pointers, arrays


What is the source code for attendance record system in c language using pointers functions arrays whichever required?

bmbmbvjmgjmgj


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.


Why does array index start with zero in C language?

Because of pointers and that all arrays are really pointers. A pointer something like *pointer can also be written as pointer[0] and *(pointer + 1) can also be written as pointer[1]


What is the use of arrays over pointers?

Arrays can be regarded as constant pointers. Example: int *pi, ai[5]; pi= ai; /* okay */ pi[0]= ai[0]; /* okay */ ai[0]= pi[0]; /* okay */ pi= (int *)malloc (10*sizeof (int)); /* okay */ ai= pi; /* NOT okay */ ai= (int *)malloc (10*sizeof (int)); /* NOT okay */


How do you handle object array?

Exactly as you would any other type of array. An object's size is determined in the same way a structure's size is determined, by the sum total size of its member variables, plus any padding incurred by alignment. However, you cannot create arrays of base classes. Arrays of objects can only be created when the class of object is final; a class that has a private default constructor, otherwise known as a "leaf" class. This is because derived classes can vary in size; array elements must all be the same size. To create an array of base classes you must create an array of pointers to those base classes instead. Pointers are always the same size (4 bytes on a 32-bit system). Static arrays are ideally suited to arrays of leaf objects where the number of objects never changes, or the maximum number of objects is finite and fixed. Although you can use dynamic arrays of leaf objects, you will incur a performance penalty every time the array needs to be resized, because every object's copy constructor must be called during the reallocation. Dynamic arrays are better suited to arrays of pointers to objects -- only the pointers need to be copied during resizing, not the objects they point to.


What is the difference between a pointer and an array in C programming?

An array is a contiguous block of memory containing one or more elements of the same type. The array identifier is a reference to that block of memory. References do not require any memory other than the memory they reference. References are not variables -- they are merely aliases for memory addresses. A pointer is a variable that can store any reference and provides indirect access to that reference. Pointers can be used to allocate arrays dynamically, which means memory is required not only for the array, but also for the pointer to store the starting memory address of the array. Once allocated, the array can be referenced directly, but the pointer is still required in order to release the memory allocation when it is no longer required. Arrays employ pointer arithmetic to locate individual elements by their zero-based index, which is essentially an offset from the reference multiplied by the size of the element type. However arrays and pointers are not the same from a programming standpoint. Your compiler may well implement references as pointers, but that is only of concern to compiler authors, not programmers. Two-dimensional dynamic arrays make use of a pointer-to-pointer variable to point to a one-dimensional array of pointers, each of which points to a one-dimensional array of the actual elements. A three-dimensional array employs a pointer-to-pointer-to-pointer to point to a one-dimensional array of pointer-to-pointer variables, each of which points to a two-dimensional array. And so on. Static arrays use less memory as there is no need to maintain arrays of pointers, but static arrays are only useful when the number of elements and dimensions are known at compile time. At runtime, arrays of pointers are required over and above the array elements themselves, in order to both allocate and deallocate the memory, as well as obtain references to the elements in the array. Pointers also have uses beyond that of dynamic arrays, including allocating any type of memory of any size, and pointing at functions which can then be passed as arguments to other functions.