answersLogoWhite

0


Best Answer

It is not possible to declare a two-dimensional array using an array of pointers in any programming language, but many programming languages support declarations of N-dimensional arrays of pointers.

The exact syntax varies with the programming language, and requires support for N-dimensional arrays and pointers. In C, the following declares an array of pointer variables, each implemented as pointer to the generic type "void":

void* array_1D[10];

The type of the expression array_1D is "void * const."

The following example expands on the previous one by declaring a two-dimensional array of "void" pointers:

void* array_2D[10][20];

The type of the expression array_2D is "void ** const."

The last example declares a 3-dimensional array of "void" pointers, which can be seen as a 2-dimensional array of arrays of pointers:

void* array_3D[10][20][30];

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Give the syntax to declare two dimensional array using array of pointers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

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 is non linear array?

What is ARRAY, explain its typesARRAY: -It is the combination of same data type or if same data is needed more then none time then we use array.Types Normally there are two types of array.(1) One dimensional array(2) Two dimensional array(1) One dimensional array: -This array is in form a list (vertical\Horizontal) the data input output or process in one dimensional array with the help of loop.The syntax of one dimensional array will be as:Array name [strength]For exampleA [5];The structure of above syntax will be as:A (0)A (1)A (2)A (3)A (4)(2) Two dimensional array: -Two dimensional array is also called a table because it consist of rows and columns. The syntax of two dimensional arrays will be as:Data type array name [rows] [columns]For exampleInt [3] [2];The structure of above syntax will be as:A [0] [0] A [0] [1]A [1] [0] A [1] [1]A [2] [0] A [2] [1]The data input output are process in this array with the help of nested loop.


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 a multi array?

A two-dimensional array is the simplest multi-dimensional array and is implemented as a one-dimensional array where every element is itself a one-dimensional array. We can imagine a two-dimensional array as being a table of rows and columns where every row is an array in its own right. A three-dimensional array is simply a one-dimensional array of two-dimensional arrays, which can be imagined as being an array of tables. Extending the concept, a four-dimensional array is a table of tables. Multi-dimensional arrays may be jagged. That is, a two-dimensional array may have rows of unequal length. Unlike regular arrays, jagged arrays cannot be allocated in contiguous memory. Instead, we use the outer array (the first dimension) to store pointers to the inner arrays. An array of strings (character arrays) is an example of a two-dimensional jagged array.


What does a 2 dimensional array do?

A two dimensional array is a one-dimensional array of one-dimensional arrays. That is, just as we can have an array of integers, we can also have an array of integer arrays. This idea can be extended such that we can have an array of two-dimensional arrays (a three-dimensional array), and so on. We typically use a two-dimensional array to represent a table of rows and columns, where each row is a one-dimensional array.


What is array of string?

An array of strings is usually implemented as an array of character pointers. Each pointer refers to a a null-terminated character array, and can be treated just as if it were a two-dimensional array where the length of each "row" is not fixed length (the null terminator marks the end of each row). The array of character pointers must be allocated in contiguous memory (as must all one-dimensional arrays), however the character arrays they point to need not be allocated contiguously with each other (only the individual one-dimensional character arrays must be contiguous).


How do you declare an array of buttons in Java?

To declare an array of buttons in Java, you would use the following syntax: Button[] buttonArray = new Button[n]; where n is the number of buttons you want in the array. This creates an array of n buttons, where each element can hold a reference to a Button object.


Differentiate single dimensional array to double dimensional array?

A single dimensional array is an array of items. A two-dimensional array is an array of arrays of items.


What String of what?

An array of strings is usually implemented as an array of character pointers. Each pointer refers to a a null-terminated character array, and can be treated just as if it were a two-dimensional array where the length of each "row" is not fixed length (the null terminator marks the end of each row). The array of character pointers must be allocated in contiguous memory (as must all one-dimensional arrays), however the character arrays they point to need not be allocated contiguously with each other (only the individual one-dimensional character arrays must be contiguous).


What is an array pointers?

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


How many types of arrays in c?

An array is simply a contiguous block of memory containing two or more elements. There are two types of array: a static array which is allocated on the stack at compile time; and a dynamic array which is allocated on the heap at runtime. Both can be one-dimensional or multi-dimensional. A one-dimensional array can be likened to a row (or column) of chessboard squares, with as many squares as required to store all the elements. A multi-dimensional array is any array with two or more dimensions. A two-dimensional array can be likened to the whole chessboard, where any square can be identified by its row and column index. However the dimensions needn't be equal. A two-dimensional array can also be imagined as a one-dimensional array where every element is simply another one-dimensional array. Three-dimensional arrays can be likened to a cube, or as a one-dimensional array of two-dimensional arrays. A four-dimensional array can be linked to a one-dimensional array of three-dimensional arrays, and so on. Although every one-dimensional array must be allocated in contiguous memory, multi-dimensional arrays can be dynamically allocated so that each dimension is itself a separately allocated one-dimensional array of pointers to the next dimension, making it possible to allocate extremely large arrays over a series of smaller allocations rather than as a single contiguous block.