C: Pointers & Memory
What the standard actually promises
A broken C program does not usually announce itself. It compiles, runs, prints the number you expected, and is wrong anyway — so the judgement worth having is not "did it work" but "what was guaranteed". Six modules of unfamiliar programs, and one verdict to reach on each, with no compiler to ask.
- Modules
- 6
- Drills
- 12
- Build steps
- 0
- Time
- ~4h
Walk out able to
Read a C program that touches memory and say where each object lives, how long it lives, and whether the standard defines what happens at all.
What you judge
Arrows and arithmetic
Which object a write reaches, and how far an offset moves.
Storage and lifetime
What dates an object, and when a pointer has outlived it.
The heap you own
Sizing a request, and the contract every block signs.
Layout and the standard
Padding, members, and the four kinds of answer.
The pitch
What you practise, and what you leave with
Not an artifact — a reflex. An unfamiliar C program, a verdict on what the standard guarantees, and the line that lost it.
You will practise
- Indirection, declarations and pointer arithmetic
- Storage duration, and pointers that outlive
- Sizing, freeing and the leaks between
- Layout, legal spellings, the four answers
Afterwards you can
- Say which object a write really reaches
- Date any object from its declaration
- Judge one heap block from malloc to free
- Sort a program into the standard’s four
Modules
6 modules, 27 items
Lessons explain one idea. Drills repeat it until it sticks. Build steps make something that exists afterwards.
- 1
Follow the arrow
~39 minName the object a write through a pointer reaches, and read a declaration cold.
- LessonSay where the write lands8 min
- LessonReach a caller’s pointer6 min
- LessonTell null from uninitialised6 min
- DrillSay which object changed10 min
- DrillRead a declaration inside out9 min
- 2
Walk the array
~40 minScale an offset by its pointee and say exactly where a pointer into an array may sit.
- LessonFence the legal addresses7 min
- LessonSay why there is no step below6 min
- LessonWatch a bounds check disappear6 min
- DrillScale the offset yourself11 min
- DrillTell an array from a pointer10 min
- 3
Where it lives, how long
~31 minName any object’s storage duration and say whether a pointer to it has outlived it.
- LessonDate the object, not the address7 min
- LessonFind the brace that ends it6 min
- LessonDrop the map, keep the duration6 min
- DrillCall the pointer valid or dangling12 min
- 4
Own the allocation
~41 minSize a request from its pointee, and judge one block against the free contract.
- DrillCount the bytes you asked for10 min
- LessonState the contract every block signs7 min
- LessonGrow a block without losing it6 min
- LessonNull it, and know what that buys6 min
- DrillJudge one block, end to end12 min
- 5
Read the struct, read the line
~31 minCompute a struct’s size, reach any member, and name the line a compiler must reject.
- DrillPlace the members and round the total12 min
- DrillSay what the operators bound to9 min
- DrillName the line that is rejected10 min
- 6
What the standard does not promise
~46 minPut a program in one of the standard’s four categories, and find the line that lost it.
- LessonTell the four answers apart7 min
- LessonUndefined is not a runtime event6 min
- LessonSort a program in two questions6 min
- DrillPut it in one of the four13 min
- DrillFind the line that loses it14 min
More in Languages
Keep going
Python Foundations
Read a program before you run it. Then write one worth showing.
Foundational~6h8 modules
Python Fluency
Choose the shape before you type. Then say it in one line.
Intermediate~5h7 modules
Python Confidence
Somebody else wrote it. Find out whether it works.
Advanced~7h7 modules
Python Craft
It works. Now make it somebody else's.
Advanced~10h7 modules
It compiled. It ran. Is it correct?
The first item is free. ~4h of focused work, at your own pace.
Advanced~4h6 modules