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

Get Learn C the Hard Way: A Clear & Direct Introduction To Modern C Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.