answersLogoWhite

0


Best Answer

C++ doesn't enforce any limits on array dimensions. Limitations are enforced by the hardware. The first limitation is available memory (including virtual memory). The larger the objects in the array, the fewer elements you can create in memory. The second limitation relates to the maximum integer that can be mapped to a size_t data type (which is dependent upon the architecture), however you're far more likely to run out of memory long before reaching this limit.

For instance, a 32-bit system has 4GB of addressable memory, thus (in theory) can accommodate an array of char with a 4,294,967,295 dimension (assuming an 8-bit char type). However, that would leave no memory for the operating system let alone the IDE, so the maximum would be somewhat lower than 4GB.

On a 64-bit system, a 4GB array of char would be perfectly feasible, even if the system only had 2GB of physical memory, due to the much larger address space available (18,446,744,073,709,551,616 bytes).

However, an array that partially requires virtual memory would be tremendously slow to access due to constant swap file access. Depending on the nature of the array, if it requires more memory than is physically available, it might be better handled via a database or as a random access file stream.

User Avatar

Wiki User

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

Wiki User

7y ago

The largest number of elements in any one dimension cannot exceed MAX_SIZE, which is the largest value that can be represented by your implementation's size_t data type (implementation-defined). However, the amount of contiguous memory physically allocated to an array is determined by the product of the dimension(s) and the size of the array type (in bytes), thus you will likely find the actual limit is much lower than MAX_SIZE might suggest.

For instance, a 32-bit implementation might define size_t as an alias (typedef) for a 32-bit unsigned integer, suggesting an upper limit of 4,294,967,295 elements (2^32-1). However, a 32-bit machine can only physically address 4,294,967,295 bytes of memory, some of which will be utilised by your operating system and other running programs. Although virtual memory can make it seem like there's far more memory than physically exists, an array allocated in contiguous virtual memory still has to be allocated in contiguous physical memory. A 64-bit machine with more than 4 GB of physical memory available could probably accommodate such an array, but a 32-bit system definitely could not.

Arrays that are too large to store in memory must be stored on disk instead.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the maximum dimension of array can be accepted in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the array of string in c?

A string in C is stored in a 1 dimension array so an array of strings is simply a two dimension array.


What is the maximum size of array in c?

Platform-dependent.


What is the Maximum limit of array size in c language?

Platform-dependent.


Write a c program to find the maximum value of 25 element in an array?

int findMax(int *array) { int max = array[0]; for(int i = 1; i < array.length(); i++) { if(array[i] > max) max = array[i] } return max; }


Write a c program to find the maximum of two numbers and print out with its position?

maxValue = function (array) {mxm = array[0];for (i=0; i<array.length; i++) {if (array[i]>mxm) {mxm = array[i];}}return mxm;}; i don't know


Columns and rows in c programming?

Do you perhaps mean -- a two-dimensional array? A two dimensional array is nothing more than a one-dimensional array where every element is a one-dimensional array. int matrix[4][5]; C is a row-major language thus the first dimension refers to the number of rows. Here we have declared an array of 4 rows, where each row is an array of 5 elements of type int.


What is the lowest subscript of an array in c plus plus?

The lowest subscript of an array in C, or C++ is 0.


How do you make a C plus plus program that arrange the the numbers in ascending order?

Heres something i whipped up in a hurry... This uses the Bubble Sort method found (related links) #include <iostream> using namespace std; int main(int argc, const char* argv) { int arraysize = 5; //Unsorted array size int array [] = { 5, 3, 4, 2, 1 }; //The array of numbers itself //Display the unsorted array cout << "Before: {"; for (int c=0; c <= arraysize; c++) { cout << array[c]; if (c != arraysize) { cout << ","; } } cout << "}" << endl; //Acctually sort the array int tmp=0; //Used for swaping values for (int loop=0; loop <= (arraysize - 1); loop++) { for (int c=0; c <= (arraysize - 1); c++) //The sort loop { if (array[c] > array[c + 1]) { //Swaps the two values in the array tmp = array[c]; array[c] = array[c + 1]; array[c + 1] = tmp; //Cleanup tmp = 0; } } } //Display the sorted array cout << "After: {"; for (int c=0; c <= arraysize; c++) { cout << array[c]; if (c != arraysize) { cout << ","; } } cout << "}" << endl; return 0; }


How do you Find the highest (maximum) and lowest (minimum) grades in an array?

You can get many example of"c programming" Reference:cprogramming-bd.com/c_page1.aspx# integer grades


Design an algorithm that accepts an array A of size N all the elements of a should be multiplied by 10 and updates the contents of A copy contents of a into array B display the result from array B?

Start dimension A[N], B[N] For c=1 to N Input A[N] Next For c=1 to N A[N] = A[N] *10 next For c+1 to N B[N] = A[N] Next for c=1 to N print B[N] Next End


How do you declare a string array and add elements to it in C plus plus?

You cannot add elements to a fixed array in C or C++. If, however, the array is declared as a pointer to an array, you can add elements by allocating a new array, copying/adding elements as needed, reassigning the new array to the pointer, and deallocating the original array.


How to write a C program to generate Fibonacci series up to 10 elements and store in array?

#include <iostream.h> #include <conio.h> #include <stdlib.h> int swap(int* , int*); int main() { int c=0; int b=1; int max; cout<<"Enter the maximum limit of fibbonacci series = "; cin>>max; if(max>0) { cout<<c<<endl; } else { exit (EXIT_FAILURE); } for(int i=0;i<max;i++) { c=b+c; swap(&b,&c); if(c<max) { cout<<c<<endl; } else { break; } } getch(); return 0; } int swap(int *x,int *y) { int z; z=*x; *x=*y; *y=z; return z; }