There's a very definite limit to the size of an array you can create on the stack as a local variable.
Depending on your OS/Compiler, the usual range for your average desktop environment is a stack limit between 1MB and 8MB.
> is there any way to address int array of 10^7 elements? i need it to solve my problem
Just do this, int *arr = new int[1000000];
but don't forget this when you're done delete [] arr;
Alternatively, an array who's scope is main, but isn't on the stack. static int arr[10000000];
Thanks for help, i've got another question
i've allocated array on heap using *arr = new int
i want also create vector of vectors<int> and it behaves exactly like array stackoverflow and crashes
std::vector<int> buckets[10000000]; //crash
then i access to vector with
buckets[index].push_back(arr[i]); // worked when there were no problems with creating buckets with smaller size
how can i convert it to heap to let me create that huge vector of vectors<int>?
and how to add ints to this new created vector on heap?
thanks in advance
some compilers also have flags to make the stack size larger. It still has an upper limit, but you may be able to extend it if you were on the edge of the default.