Why we cannot make array of size greater than 10^5 inside the function?
Array size inside function
Hey @himanshugupta8
In most of the cases I found it close to 10^6
One of the main reason is Limited amount of memory available
To dive deeper ,u can refer to this : https://stackoverflow.com/questions/216259/is-there-a-max-array-length-limit-in-c
If memory issues then how come we are able to make array of 10^6 outside the function?
Hey @himanshugupta8
In main
the array is allocated on stack whose size is equal to 8MB
The global array is allocated on data segment whose size in == available memory
So inside main u can allocate
int array of 2*10^6 easily which is 8MB
char array of size 8*10^6 which is again 8MB
: https://ide.codingblocks.com/s/380674
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.