Brainlag
  1. C
  2. Advanced
25/38 lessons

Debugging C on purpose

40 min5 exercisesPremium

A real debugging method for C: shrink the failing input, trace the state with printf, guard assumptions with assert and read runtime errors for clues.

The skill
Track down a C bug with a method: shrink the input, trace the state, assert assumptions and halve the search.
You make
Fixes for a streak counter, a word counter and an average, and a search that finds the first broken version of a game.

Premium lesson

£7.99 a month or £59 a year. Cancel any time.

Builds on 24 Checkpoint: memory you manage. Free to try: C Foundations and the playground.

Step 1 of 9
exercise_1.c

You've reached the good stuff.

5 exercises in this lesson, checked as you type. Premium opens every lesson after Foundations, in all four courses.

C, 32-bit: int and pointers are 4 bytes