what is the maximum range of integer array for initialization??

i have tried like that int arr[1000000] to initialize but it crashed my programm.but if i do int arr[100000] it works fine..why is that and what is the maximum range of integer array initialization??
> what is the maximum range of integer array initialization??

Depends on the storage duration and the implementation.

static int arr[1000000] ; would be supported by most implementations.
you are writing it static..is simply int is posible??
int array[1000000]

Assuming an int is 4 bytes, that's approximately 3.8 Megabytes.
In Visual Studio, I believe the stack size is 1 MB by default, and on other implementations it goes up to 4 MB. However, all compilers provide settings to change the default stack size I believe.

But, you wouldn't have this problem to begin with if you used dynamic (heap) memory instead.
Last edited on
You would still be limited by the amount of free ram on your computer though.
> is simply int is posible??

Use std::vector<int> arr(1000000) ;
http://www.mochima.com/tutorials/vectors.html
Topic archived. No new replies allowed.