CSC 271
Homework 4

Assigned 20 Nov
Due 2 Dec

Write a C or C++ program named "heads" which prints out the first line(s) of each of the files it is given as arguments.

The basic version of the program simply takes a list of filenames on the command line and prints the first line of each one to stdout. If one of the files is not found, print an information error message (e.g. "File 'foo.snark' not found.") to stderr and go on to the next filename.

The more advanced version adds an option to allow the user to specify how many lines of a file to print: if the user gives a "-7" option, the program will print the first seven lines, rather than just the first line, of all files from then on. For example,

heads foo -3 snark -5 boojum beeblebrox
would print out the first line of foo, the first three lines of snark, the first five lines of boojum, and the first five lines of beeblebrox (assuming all four of those files actually exist).
Last modified: Wed Nov 19 16:12:04 EST 1997
Stephen Bloch /