why codechef compiler is unable to provide contiguous memory location to the array of size greater than 10^6 in local scope statically whereas it is possible dynamically.
1 Like
Yes, you cannot locally declare an array of size 10^6 in gcc compiler because when you declare an array in a function it gets allocated in stack memory and this memory has less space as compared to heap memory.
Instead of direct declaration use malloc function for the declaration(Array will be allocated in heap memory).
It does not matter whether you declare the array of such size statically or dynamically, in both the cases yo will get the run time error.
1 Like