Brainlag
  1. Library
  2. Concepts
  3. C

The stack and the heap

Local variables live on the stack and vanish when their function returns. malloc gives you heap memory that stays until you free it.

C12 minPremium

Premium

Inside: an interactive visualisation, 2 short explanations, a runnable example and 1 checked exercise.

See Premium£7.99 a month. Already Premium? Sign in

Code editor. Press Control or Command plus Enter to run the code. Tab indents; to move focus out of the editor, press Escape and then Tab.