You are trying to enter a character ('H') into an integer (
decimal). You are also trying to compare an integer (
number) with a character (' ', or 32).
I have a few recommendations:
1) replace
decimal with the datatype of char
2) Change lines 38 and 61 to use a logical AND rather than binary AND
3) Remove your throw statements from within the cases and instead throw from inside the
default
case
4) Put in a check for if the decimal is larger than 65536, and if so, throw
5) Rather than throwing error codes (what does "99" mean?) throw meaningful data, such as
std::runtime_error or
std::range_error(see
http://www.cplusplus.com/reference/stdexcept/ )
6) Have a catch block that catches arbritatry exceptions, and another to catch everything (just in case) (this isn't really necessary, but I like to know that my program crashed due to exception rather than something like segfault). Here is an example:
1 2 3 4 5 6 7 8 9 10
|
try {
//... main function
}
// specialized catch blocks for error handling, and then:
catch (std::exception& e) {
std::cerr << "Unhandled exception caught: " << e.what() << "\n";
}
catch (...) {
std::cerr << "Unrecognized expection caught.\n";
}
|