Learn C Programming

Lesson 2 of 7 · Recursion

Module 8 · Recursion

The Call Stack, Frame by Frame

Free with an accountReading

Kenji shows Amara a short recursive function and bets she cannot say what it prints. Bob answers first: the deepest call sets square last, so every line must say 1.

Sign in to read

This lesson is free, with an account

An account costs nothing and opens every lesson in this track that is not marked Pro, on every device you read on.

What is inside The Call Stack, Frame by Frame

  1. One call, one stack frame
  2. Push and pop: the stack grows with every call
  3. Amara's paper trace: one row per call
  4. The return address, honestly
  5. Read the frames in GCC's own listing
  6. At -O2 the recursion is gone
  7. The stack has a limit: measure it
  8. Why a judged problem states an input limit