There are two parts to this assignment. Please download this zip file.
Part 1. Write a C program called range.c
that prints to standard output a range of lines from a text file. The program should take command-line arguments of the form
range 10 20 filename
or
range 10 20
and print lines 10 through 20 of the named file, or lines 10 through 20 from standard input. If there are not enough lines of input, the program should print what it can.
Part 2. Write a C program called last.c
that prints to standard output the last ten lines of a text file. The program can be used from the command-line with
last filename
or
last
If there is no filename, last
should process standard input.
Turn in a zip file called CS59000Hw1Surname.zip
(where Surname
is your last name) containing your C programs range.c
and last.c
.
This assignment is due Thursday, January 22.
This assignment makes use of a few basic Command-line interface ideas like IO redirection, stdin/stdout, and command-line arguments. Here are some explanations of these ideas.
Also, be sure to look at the Unix Tutorial for Beginners and Software Carpentry - The Unix Shell