In C++, When I declare an array inside the function which was of size 10^7. I was unable to do so. But, when I declared this array with the same size globally, everything was running super fine. What I mean to say is=> Let say I declare the array in a function
void ArrayReturn(){
int N = 1e7+10;
int arr[N]={0}; //When I try to output the content of this array
// there is a blank screen only.
// Now I start performing seive
}
But, at the same time when I declare arr globally, the output comes fine
int arr[10000010];
void ArrayReturn(){
//perform sieve
//output which uses the content of this array, comes fine now.
}
So, I just wanna know whether this issue is because something related to memory assigned to a function over stack is limited, or is there something else that I am missing or don't know at all?
Kindly explain.