What is the difference between stack and heap memory in C?
| Stack | Heap |
|---|---|
| Local variables and function calls | Memory from malloc(), calloc(), realloc() |
| Managed automatically | Managed by the programmer with free() |
| Very fast | Slower |
| Limited size (stack overflow) | Much bigger |
| Memory ends when the function ends | Lives 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. |