Step Into C · Lesson 11 · Memory
Dynamic Memory
Stack vs heap, malloc / calloc / realloc / free, memcpy and memset.
- ~35 minreading and coding
- 4missions
- membersaccess
- Clanguage
Part of Step Into C. The full lesson, its missions and the real compiler and debugger are in the course. Try a free lesson first to see how it works.
These are declared in <stdlib.h>:
In this lesson
- Two places to keep data
- malloc and free
- calloc: zeroed memory
- realloc: grow or shrink
- The classic heap bugs
- memcpy and memset
- Returning heap memory from a function
Missions
- First allocation
- Duplicate a string
- A growing buffer
- Zeroed and set