When you declare an array, you push it onto the stack.
When you call malloc (), memory is taken from the heap.
The stack is usually more limited than the heap and is usually transient (but it depends on how often you enter and exit the function declared by this array.
For such a large (perhaps not by today's version?) Memory, malloc it is a good practice, assuming you want the array to last a bit.
tchen
source share