Project 8: C Stacks

The goal of this project is to practice using pointers for programming in C.

1. Introduction

In this project, you will be doing something familiar (implementing stacks two ways: with an array and as a linked list) in a manner unfamiliar (using dynamic arrays and pointers in C). You will be writing two library files (each with both a header and source file) to implement stacks. In either case, you will write a struct that represents the stack itself and a series of functions which provide the behavior of the stack.

2. Setup

Copy the driver program

cp /cslab/class/cs245/cfun/stackdriver.c .

3. Your task

First, open the driver program and look it over. You'll see that it expect the following things:

Then, write the two libraries. Remember what we learned about how to compile and link. Be careful on your use of pointers and your allocating and deallocating.

4. To turn in

Turn in a hard copy of a typescript where you compile and run both versions. For the array version, run your program twice, once where the user enters data until the stack is full, and the other where the user quits by entering -1.

DUE:Wed, Dec 12, 5:00 pm.


Thomas VanDrunen
Last modified: Fri Nov 30 15:59:34 CST 2007