O'Reilly logo

Learn C the Hard Way: A Clear & Direct Introduction To Modern C Programming by Zed A. Shaw

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Exercise 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.

As usual, type this whole program in and get it working, then we’ll discuss it.

ex17.c

  1   #include <stdio.h>   2   #include <assert.h>   3   #include <stdlib.h>   4   #include <errno.h>   5   #include <string.h>   6 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required