next up previous
Next: C Primer CS 1005 Up: Coding Style for CS2005 Previous: Ease of use

Robustness

Your program should tolerate unexpected input to a certain degree. For example, inputting a string when a number is expected should lead to a repeated user input request in interactive use and to an error message when reading from a file. At a minimum, the program should end with an appropriate error message (using the assert-function). Unexpected conditions should not lead to endless loops or simple continuation of the program with invalid or wrong data. Be careful with string-input as the simple >>-operator provides no mechanism to catch input strings that exceed the available space (i.e., you can assign a 10-character string to a char[5]-variable with undefined results).

Andreas Koeller
2000-06-04