Learning Outcomes
In this project you will demonstrate your understanding of arrays, strings, and functions. You may also use typedefs and structs if you wish (see Chapter 8) – and will probably find the program easier to assemble if you do – but you are not required to use them in order to obtain full marks. You should not make any use of malloc() (Chapter 10) or file operations (Chapter 11) in this project.
Text Formatting
We all want our written work to look good. But when preparing text with a text editor it is annoying
to (for example) try and adjust the line-lengths in a document every time we alter it, or if we decide
that the text width needs to be narrower. So we use approaches that let us describe the layout of
documents, and apply a compiler-like tool to generate the exact formatting that we are after. For
example, this document (and most other things you will see in this subject, including the textbook)
was prepared using a typesetting tool called LATEX, and you can see the source code for it linked from
the LMS/FAQ page. Use of LATEX allows math expressions like limn→∞ Pn
i−1
(1/i2
) = π
2/6 (plus far
more complex expressions too) to be elegantly presented, and allows careful and consistent formatting
to be applied throughout long documents. A WYSIWYG1
(or more usually, WYCSIAYCG2
) tool like
Word might be employed to write a one-page reference letter, but for technical work academics in the
maths, physics, and computing sciences almost always prefer LATEX. (It was originally invented by one
of the most famous computer scientists of all, Stanford University’s Donald E. Knuth, and now has
a world-wide community of developers and language extenders.) Similarly, html tags in conjunction
with a style sheet file describe how the contents of a web page are to be rendered and presented.
In this assignment we are going to journey back to the 1970s, and implement a simple text formatting tool based entirely on fixed-width terminal fonts and character-based output.3 The formatting
“commands” will be indicated by input lines that start with a period, “.”, with the command indicated
by the letter in the next character position. For example, the characters “.p” in the first two positions
of a line are (in this simple language) the signal to start a new paragraph in the output.
Get Free Quote!
339 Experts Online