Examples of Good Headers
Program Header
/******************************************************
* *
* Author(s): Brenda Sonderegger, Jane Doe *
* Date Last Modified: Oct. 15, 1997 *
* *
* CS210 *
* Assignment 1, Simple I/O *
* *
* Description: User will input an integer, character *
* and float using standard input. The *
* program will output the input values. *
* *
******************************************************/
File Headers for a C header file (stdio.h)
/******************************************************
* *
* Name: myio_c.h *
* *
* Author(s): Brenda Sonderegger, Jane Doe *
* Date Last Modified: Oct. 15, 1997 *
* *
* Contents: Prototypes for robust user input functions*
* *
******************************************************/
void get_int(int *val);
/*****************************************************
* Precondition: Actual parameter has been declared *
* Post_condition: Formal parameter will hold a valid *
* integer value. *
* Parameters: a pointer to an integer that will hold *
* the value input by the user *
* Return value: none *
* *
* Description: User input of 12a, 2.4, a34, abc, *
* will trigger an error message to the *
* user. If an error occurs, the input *
* stream will be completely cleared and *
* a user prompt will ask the user to try*
* again. *
*****************************************************/
Header for a source code file
/******************************************************
* *
* Name: myio_c.cxx *
* *
* Author(s): Brenda Sonderegger, Jane Doe *
* Date Last Modified: Oct. 15, 1997 *
* *
* Contents: Code for the functions in myio_c.h *
* *
******************************************************/
/*****************************************************
* *
* void get_int(int *val); *
* *
* Author: Brenda Sonderegger *
* Last Modified: Oct. 15, 2000 *
* *
* You could optionally include the info from the *
* function headers in the .h file here as well as in *
* that file. Note that individual functions may only*
* have ONE author for this class. *
*****************************************************/
void get_int(int *val)
{
/* code for the function - note this is a void function
so is actually a procedure. Remember all subprograms
in C are called functions regardless of whether or not
the return a value or are void */
}
/*****************************************************
* *
* void get_int_bound(int *val, int low, int high); *
* *
* Author: Jane Doe *
* Last Modified: Oct. 21, 2000 *
* *
* You could optionally include the info from the *
* function headers in the .h file here as well as in *
* that file. Note that individual functions may only*
* have ONE author for this class. *
*****************************************************/
void get_int_bound(int *val, int low, int high)
{
/* code for the function - note this a void function so
adheres to the concept of a procedure */
}