Step Into Labs

Step Into C · Module exam · Memory

Exam: The Word Stack

Store any number of words on the heap, give them back in reverse, and leak nothing.

Part of Step Into C. The full module exam, its missions and the real compiler and debugger are in the course. Try a free lesson first to see how it works.

You do not know how many words are coming, or how long any of them is. A fixed-size array would either waste memory or overflow. Build a word stack that grows on the heap exactly as much as it needs, prints the words back in reverse order, and returns every byte it rented. The starter counts your blocks, so a leak cannot hide.

In this module exam

Missions

  1. Grow, reverse, give back