CSC 357 Lab 3
Details of C Arrays, Pointers, and Structs; UNIX Make



ISSUED: Monday, 16 April 2007
DUE: At beginning of lab Wednesday, 25 April, on paper
POINTS POSSIBLE: 130
WEIGHT: 2% of total class grade
READING: Lecture Notes Weeks 2 and 3, GNU Make manual, K&R Ch 5-7

Tasks:


  1. Read Sections 1-3 of the GNU make manual at http://www.gnu.org/software/make/manual/make.html. Also, look at the example Makefile in the 357 lab2 directory, and the simpler examples given below in this lab's writeup. This is in preparation for the Makefile you must supply for Programming Assignment 2.

  2. Provide the explanations of program behavior (or non-behavior) asked for in the example program person-record-test.c. The explanations are for the following program lines: 68, 69, 72, 73, 92, 101, 103-107, 110. Your explanations should be as short as possible to get the job done; verbosity will result in deducted points. Support your answers with pictures of memory where appropriate.

    The format for each of the four explanations for lines 68-73 is the following:

    Line X: The program fails to [compile or execute properly] because ... .

    The format for each of the nine explanations for lines 92-110 is the following:

    Line X: The program outputs ... because ... .

Deliverable

Task 1 does not have a specific deliverable for this lab (you will turn in a Makefile for programming assignment 2). Submit your work for Task 2 on paper, at the beginning of lab Wednesday 25 April.

Scoring Details

10 points for each question -- thirteen explanations in total.

Collaboration Allowed

Collaboration with a lab partner IS allowed on all aspects of this assignment, but everyone must submit their own paper deliverable (and not a photo copy of your lab partner's paper).

How to Submit the Deliverables

Again, submit your work on paper, at the beginning of lab, Wednesday 25 April.

Some Additional Makefile Examples

The following two makefile examples are simplified versions of the Makefile provided for the linked list example of Lab 2. The comments explain what's going on in each file. We'll discuss further in lab. A very simple compile-only linked-list Makefile:

#
# This is a simple Makefile that compiles the C source files for the linked
# list example.  This Makefile does compile the Java code, or run the program
# tests.
#
# This Makefile is also not as efficient as the full-blown Makefile, since it
# does not take advantage of make's "smart" recompilation feature, that only
# recompiles a .c file if the source for the file is newer than the last time
# it was compiled.
#

CFILES = linked-list.c list-node.c linked-list-test.c

compile:
                        gcc -Wall -ansi $(CFILES) -o linked-list-test

clean:
                        rm linked-list-test
"Smarter" linked-list Makefile:

#
# This is a simple Makefile that takes advantage of make's "smart"
# recompilation feature, by having the compilation depend on the .o files
# instead of .c files.  Using this feature of make, a .c file is only
# recompiled if it is newer than it's corresponding .o file.
#

OBJS = linked-list.o list-node.o linked-list-test.o

linked-list-test:       $(OBJS)
                        gcc -Wall -ansi $(OBJS) -o linked-list-test

clean:
                        rm linked-list-test *.o




index | lectures | labs | programs | handouts | solutions | examples | documentation | bin