Grab our bagsimple code if you haven’t done so in last lecture:

cd ~/cs50
cp -r /thayerfs/courses/22spring/cosc050/workspace/bagsimple .
cd bagsimple/

and work in your group to modify the Makefile so it adds a phony test target, enabling you to later type

make test

and see it build bagsimple (if necessary) and run a test of the bagsimple program.

Extra exercise: read this page to learn more about dynamic memory allocation and array of pointers to deal with unknown array size. The readlinep code is another great example.

Solution

Makefile-test.