April 18, 2007
Assignment written by Julie Zelenski, and revised by me.
Assignment 2 operates as a warm-up for the more intense Assignment 3 experience.
that you’ve had some practice with
s, pointer arithmetic, and casting, you’re in a
position to write a few generic container data structures to imitate the functionality of the
STL—without using templates.
This requires some very careful programming, and
mandates a full understanding of the more difficult C library functions:
You’re expected to use each and every one
of these, relying on the man pages to get the documentation.
This assignment is based on an assignment given out in previous quarters.
consistently identified that assignment to be the most demanding, so I can only assume it
will be challenging for everyone here as well.
In fact, students
to get much more
practice with the
and raw dynamic memory allocation when our introductory
programming classes were taught in C without the added C++.
You’re at something of a
disadvantage when compared to those students who complained even then.
While I have
scaled the assignment back a little, it’s still a bear of a project by any measure.
Note: you’ll be coding in straight C.
There are no classes, no methods, no templates, no
references, no operator
s or streams.
You define new types as exposed
s (C’s best imitation of the
), but all routines that initialize, destroy, and
otherwise manipulate those
s must be implemented as functions.
Due: Wednesday, April 25
at 11:59 p.m.
is a more flexible extension of C's built-in array type.
It has some of the same
basic properties: it is managed as a contiguous region of memory, all the elements in any
one array must be the same size, and element indexing starts at 0, not 1.
But this C
differs in that it can automatically grow when elements are appended, and it can splice
elements in and out of the middle.
Through the use of client-supplied function pointers, it
can sort itself, iterate over its elements, and search for an element of interest.