Chapter 22. Putting It All Together

For there isn’t a job on the top of the earth the beggar don’t know, nor do.

Rudyard Kipling

In this chapter, we create a complete program. Every step of the process is covered from setting forth the requirements to testing the result.

Requirements

Before we start, we need to decide what we are going to do. This step is very important and is left out of far too many programming cycles.

This chapter’s program must fulfill several requirements. First, it must be long enough to demonstrate modular programming, but at the same time be short enough to fit inside a single chapter. It must be complex enough to demonstrate a wide range of C features, but be simple enough for a novice C programmer to understand.

Finally, the program must be useful. Usefulness is not simple to define. What’s useful to one person might not be useful to another. We decided to refine this requirement and restate it as “The program must be useful to C programmers.”

The program we have selected reads C source files and generates simple statistics on the nesting of parentheses, and in the ratio of comments to code lines.

Specification

The specification for our statistics program is shown in the following sidebar:

Get Practical C Programming, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.