Printing Files

May 28, 2010

A useful utility program is one that neatly prints a file or set of files, often a program listing, with each page labelled with filename and page number and each file starting on a new page.

That program turns out to be somewhat tricky to write. In ancient times, before laser printers, most output was to dot-matrix printers using fan-fold paper, and it was amusing to see programs that couldn’t count lines correctly, so the output drifted up and down on successive pages. Another common error of file printers is to print a useless blank page after a file that exactly fills the previous page.

Your task is to write a program that neatly prints a file or set of files. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

About these ads

Pages: 1 2

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 576 other followers

%d bloggers like this: