Last modified: 2020-07-03
This is a course page of
David Casperson
Associate Professor
Computer Science
University of Northern British Columbia

CPSC 101: Computer Programming II (2007)

Quick Links:

Producing pretty-printed C++ code

The enscript command can be used to produce nicely formatted listings of files. I prefer enscripting with
    enscript -2rG --prettyprint=cpp --output=output.ps file.cpp
This produces 2 pages of code per page in landscape (rotated) mode with Gaudy headers. The --prettyprint=cpp is only suitable for C++ code and causes some keywords to be highlighted.

Typing
    enscript --help
gives you a complete list of options.

Note that enscripted code looks ugly if it contains line-wraps. For this reason, keep your code lines to about 80 characters in length. If you consistently get line-wraps think about how to change your coding style and/or use of text editors.

Producing Script files for labs

The
    script file
command causes all of the commands that you are executing in a shell to be captured in file. When you are finished collecting command and output that you wish to be in your script file, type ctl-D (the unix end of file character).

You should script the compilation and running of your programs. I am not overly concerned about fraudulent programming, and prefer to see enscripted code to using inside script-files.

Cleaning Script files

One of the problems with the script program is that it captures all of the control character information that your shell produces to create underlining and to make corrections when you type delete. In order to remove this junk, use the scriptfix program as in
    scriptfix script-file > clean-script-file

Click to return to the cpsc 101 main page.

Home page Semesters Site Map
go back Winter 2007 go forward
2024-12 other links

Dates
CPSC 101
Syllabus
Old Exams
Labs
Project
David’s Schedule

fall-2024