Brainlag
  1. C
  2. Advanced
24/38 lessons

Checkpoint: memory you manage

Checkpoint45 min3 problemsPremium

Three problems on your own: load a file into a growing heap array, find a leak with a block counter, and build a list of heap strings that frees cleanly.

The skill
Combine malloc, realloc, ownership, double pointers and files without help, and free every block you make.
You make
A step counter that loads a file into a growing array, a leak fix and a playlist of heap strings read from a file.

Premium lesson

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

Builds on 23 Reading and writing files. Free to try: C Foundations and the playground.

Step 1 of 4
exercise_1.c

You've reached the good stuff.

3 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