Click here to Skip to main content
16,016,306 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how many integers i can enter an integer array?
Posted

Clearly, an integer array holds exactly as many integers as the size that you have created it.

Now, how big an array you can create depends on the environment that you are working in. I've been doing some work on software for a computer that has only 1 K of RAM total. Another program I maintain runs on a computer with has a one whole Megabyte of RAM. I also do software on a PC that has gigabytes of RAM. I would be able to create a much larger array on the PC software than the others. What the limit is depends on your environment and tools.

Also, the size of an array that you can create as an automatic variable is likely to be more limited than one that is dynamically allocated.

Personally, If I was confronted with creating a humongous array, my first reaction would be to think about if it was really necessary or if there might be a better way to do things. I have gone the humongous array route, but not often.
 
Share this answer
 
About half a billion. Attempting to compile the following:
C++
int arr[2147483647];

Produces the error:
total size of array must not exceed 0x7fffffff bytes

Attempting to compile the following:
C++
int arr[2147483647 / 4];

Produces the error:
automatic allocation exceeds 2G

Attempting to compile the following:
C++
int arr[2147483647 / 4 - 1];

Produces the error:
An internal error has occurred in the compiler.

Attempting to compile the following:
C++
int arr[2147483647 / 4 - 50];

Caused an error dialog to pop up (I think the compiler threw an exception). The following compiled fine:
C++
int arr[2147483647 / 4 - 200];
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900