+ 2

What are the differences and functions of heap and stack memory?

1st Apr 2019, 5:03 AM
MrGernae - avatar
2 Answers
+ 5
Heap used for Dynamic memory allocation. Ex - ln C, if you allocate memory using malloc(), calloc() functions. Stack is used to store temporary things like local variables, function call addresses etc.,
1st Apr 2019, 6:07 AM
Kuri - avatar
Stack is working according to LIFO principle: last in first out. If you pop data from the stack you will get the last data you pushed on the stack. You can peek a first data item from the stack without to remove from the stack as well.
10th Apr 2019, 10:21 PM
Paul Schroeder
Paul Schroeder - avatar