|
Computer Science 432 Operating Systems Williams College Fall 2006
|
|
Lab 0: Getting Reacquainted with C and Unix
Due: 9:55 AM, Tuesday,
September 12, 2006
- Send me mail at terescoj@cs.williams.edu with a brief (a couple sentences) indication
of your level of experience with the Unix operating system and its
variants, plus a list of other operating systems you have used. Also
include list programming languages you have used and your proficiency
in each, and anything else you'd like me to know about your background
coming in. (0 points)
- (0 points) Log into and familiarize yourself with your CSLab Unix account.
- Copy the C program here that computes the late
penalties for this course to your CSLab Unix account. Compile and run
it, redirecting your output to a file late.txt. (1 point)
- Copy the file /home/faculty/terescoj/shared/make-example.tar to your CSLab Unix
account, either from this link, or from . It is a "tar file" of a
small C program that demonstrates the use of multiple source files and
Makefiles. Extract the files (tar xvf make-example.tar)
and compile the program with make. In a plain text file called
make.txt, briefly describe how make uses the rules in the
Makefile to produce the executable main. (1 point)
- You have seen Java applications that take command-line
parameters (the String args[] parameter to main). Write a
C program that takes an arbitrary number of command-line parameters,
each of which should represent an integer value. Print out the sum of
the values provided. Call your C program argadder.c and include
a Makefile that guides compilation of your program into an
executable argadder. (3 points)
Hint: See main.c in the make example, and note that the
parameter argc to the main function is a count of how many
command-line strings are included in the argv array of strings.
Also, argv[0] is not the first parameter, it is the program name
itself, and this array entry for the program name is included in the
value of argc.
Aside: Why can Java get away with just a single array of Strings, while C also requires the extra int argc parameter?
To submit this lab, create a "tar file" called lab0.tar that
contains your files to be submitted (late.txt, make.txt,
argadder.c, Makefile).
To do this:
tar cvf lab0.tar late.txt make.txt argadder.c Makefile
Then use the turnin utility on any FreeBSD system in the lab to
submit your work:
turnin -c 432 lab0.tar
Please use the exact filename specified (for this lab and all
semester). Don't include your name in the tar file name. The turnin utility will store things in a subdirectory based on your Unix
userid. Consistent filenames make my job when extracting everything
for grading, and you don't want to annoy your grader with misnamed or
missing files just before he grades your assignment.