Schwartz & Christiansen Chapter 6 Exercises


1.  Write a program that acts like cat, but reverses the order of the lines (for) all
the lines from all the files specified on the command line or (for) all the lines from
standard input if no files are specified.  (Some systems have a utility like this
named tac. 

2. Modify the program from the previous exercise so that each file specified on
the command line has its lines individually reversed. (Yes, you can do this with
only what's been shown to you so far, even excluding the stroll in Chapter 1,
Introduction).

3. Write a program that reads a list of strings on separate lines, and prints the
strings in a right-justified 20-character column.  For example, inputting 
hello, 
good-bye 
prints hello and good-bye right-justfied in a 20-character column.  (Be sure
your program is actually using a 20-character column, not a 21-character
column.  That's a common mistake.)

4. Modify the program from the previous exercise to allow the user to select the
column width.  For example, entering 20, hello, good-bye should do the same
thing as the previous program did, but entering 30, hello, and good-bye should
(right-)justify hello and good-bye in a 30-character column.

Questions about the questions? Send mail to Robert Katz: katz@cis.highline.ctc.edu
Last Update January 19, 2000