Video Coming Soon...

Created by Zed A. Shaw Updated 2026-11-26 20:48:52
 

17: Heap and Stack Memory Allocation

In this exercise, you're going to make a big leap in difficulty and create an entire small program to manage a database. This database isn't very efficient and doesn't store very much, but it does demonstrate most of what you've learned so far. It also introduces memory allocation more formally, and gets you started working with files. We use some file I/O functions, but I won't be explaining them too well so that you can try to figure them out first.

WARNING: Big Jump Ahead! You're going to want to take your time with this one. It's jumping into some new techniques but I believe you're ready. Just stick with it, take it slow, and build the code slowly.

This time the code is larger and more complex so you should not type this in before compiling it. Now you should be more strict about typing it in using small chunks of code and compiling as you go. The way to type this code is this:

  1. Get the the main structure of the code laid down and compiling. That means create just empty functions and do this is small bites.
  2. Be sure to run your compiler over and over to check your work as you go.
  3. Implement each each function slowly, running the compiler to check your work.
  4. If you do it right, you'll do the functions in the order they're used, and at the end it should "snap" into place and work.
  5. If it doesn't work then now is the time to practice debugging. Get your debugger, use print debugging, and figure it out.

Debugging is an essential skill in programming so don't try to avoid it or give up when you encounter bugs. You should look at bugs in your code as blessings. Each bug you write is training for solving bugs later.

Here's the code:

View Source file ex17.c Only

Previous Lesson Next Lesson

Register for From Impostor to Programmer

Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.