Step Into C · Lesson 9 · Memory
How Memory Really Works
Watch variables, copies, pointers, the stack and the heap change byte by byte, then fix the classic bugs.
- ~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.
Pointers, the stack, the heap and most crashes in C stop being mysterious once you can see memory. This lesson shows it to you. Every scene below is a real C program with a live picture of memory next to it. Press Step (or the → key) to run one line at a time, and ◀ to go back.
In this lesson
- The one picture you need
- Calling a function copies
- Addresses: telling a function where to look
- Arrays are neighbouring boxes
- The stack is reused
- The heap: memory that outlives functions
- Use after free
- Real addresses
- Now fix it yourself
Missions
- Make swap swap
- Room for the zero
- A counter that survives
- Plug the leak