Brainlag
  1. C
  2. Advanced
22/38 lessons

Pointers to pointers

30 min5 exercisesPremium

Use int ** and char ** in C: let a function change the caller's pointer, hand back heap memory through a parameter, and work with arrays of strings.

The skill
Use pointers to pointers to change the caller's pointer and to work with arrays of strings.
You make
A loader that hands back heap memory, a name sorter that only moves pointers, a deep copy of a list and a chat command parser.

Premium lesson

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

Builds on 21 Who frees what: ownership. 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