All of our example programs have contained the kinds of comments that
we expect you to use in your programs. But just to be sure that you
understand, take a look at ``comments.c'' (or view it
directly).
Each program file should contain a comment header with the following
information:
- What the file contains. In this case, the comment tells us that it
contains a program, and tells us what the program does.
- Who originally created the program, and when. This is helpful if we need
to find someone to ask questions.
- A history of when modifications were made, who made them, and what the
modifications were. Again, especially in large projects with more than one
programmer, this helps let the reader know who might know more about the
program.
So far, all of our programs have consisted of a single main function.
We will shortly begin to study larger programs composed of multiple
functions. At that time you will notice a change in the comment
conventions of our programs. In addition to a header comment
explaining the contents of the file, you will see a comment before
each function explaining what the function does. You should also
adopt this convention when the time comes. Just follow our example.
It is not usually necessary to use comments to explain how a
function works. Given a well-written function and a comment
explaining what the function does, it is usually not too
difficult for a reader to figure out how it is done. We'll have more
to say about this point when we study functions.
Hamlet Project
hamlet@cs.utah.edu