I need help understanding why the exception handling is not activating with this code. When I input a letter instead of a number, I get a runtime error.
When you throw the exception, it does not go the catch statement inside main because `throw` statement is short circuiting just like a `return` statement.
So when you throw the int, the code just exits main and whatever called main (the OS in this instance) gets the exception
It's because you are trying to read in an integer, but when you enter a character, `x` is just set to zero which is why you get a 0 at the end.
Read everything in as a string. Check each character in the string to see if they are non-digit. If you find one that is non-digit, you throw your exception.
If the string only contains digits, convert it to int using std::stoi