What is the difference between stack and heap memory in C?

StackHeap
Local variables and function callsMemory from malloc(), calloc(), realloc()
Managed automaticallyManaged by the programmer with free()
Very fastSlower
Limited size (stack overflow)Much bigger
Memory ends when the function endsLives until freed

See Dynamic Memory Allocation and Recursion.


Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.