8/15/2016 5:07:08 AM
Karan Luther4 Answers
New Answer@Apoorva, stack being "fixed" is not really true. In contrast to heap you cannot allocate memory on the heap freely, i.e. as you like. Nevertheless, stack is dynamic, too. Example: recursive functions. For every call to a function, the local memory required for this function is allocated. If the depth of recursion depends on user input, the amount of memory required is not known when the program is started. Therefore, the difference between stack and heap is not "dynamic" or "fixed", it's how freely / self-determined you can allocate memory on it.
You can allocate heap memory according to requirement by using codes when you don't know what the file size is gonna be. Stack is fixed
SoloLearn Inc.
4 Embarcadero Center, Suite 1455Send us a message