Tom Kelliher, CS23
Feb. 28, 1997
Outline:
#ifndef __MISC_H #define __MISC_H const int MAX_LEN = 100; struct Num { char digits[MAX_LEN]; int len; }; enum Operator {INVALID, ADD, MULTIPLY}; int getNum(char num[], int &digits, int max); Operator getOp(); void reverse(char *num, int n); void print(Num a); void die(char *s); int add(Num &c, Num a, Num b); int multiply(Num &c, Num a, Num b); #endif
My problems in debugging this & the print function:
What are the ``boundary cases?''
Only really one good way to do this: one character at a time.
Pseudocode:
Skip over whitespace; Error check: EOF or non-digit; Skip over leading zeroes; Check if number is zero; Error check: EOF or non-digit; Read number & record number of digits; Error check: too many digits. Reverse number;