Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the maximum number of dimensions allowed for an array in C++?

Tags:

People also ask

What is the maximum dimension of an array in C?

There is no fixed limit to the size of an array in C. The size of any single object, including of any array object, is limited by SIZE_MAX , the maximum value of type size_t , which is the result of the sizeof operator.

What is the maximum number of dimensions an array can accept?

More than Three Dimensions Although an array can have as many as 32 dimensions, it is rare to have more than three.


You can declare a very simple array with 10 elements and use it that way :

int myArray[10];
myArray[4] = 3;
std::cout << myArray[4];

Or declare a 2d array with 10x100 elements as int myArray[10][100];

Even create more complicated 3-d arrays with int myArray[30][50][70];

I can even go as far as writing :

int complexArray[4][10][8][11][20][3];
complexArray[3][9][5][10][15][3] = 5;
std::cout <<  complexArray[3][9][5][10][15][3];

So, what is the maximum number of dimensions that you can use when declaring an array?