We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Stack free

In C, we don't have a lot of abstractions at our disposal. There are no classes, destructors, functors, monads, made-up-category-theory-words, etc.

We've got data. And we've got functions. Just the way God Dennis Ritchie intended.

So, to make it easier to work with our Stack, we're going to build our own little free function that will clean up all the memory that we've allocated for our stack.

Assignment

Complete the stack_free function.

You can assume all the elements inside the stack are already freed. That's not our problem.