From the course: Debugging in C++ with Visual Studio Code
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Erroring out - Visual Studio Code Tutorial
From the course: Debugging in C++ with Visual Studio Code
Erroring out
- [Instructor] Here we have a simple calculator program that requests a string with an operation and shows the result. This operates in an endless loop until the user enters lowercase Q. Let's see it working. Alright, let me enter the example expression, 5 plus 3. Okay, the result is 8. Now let's see what happens if I enter an invalid string like this. Hmm, we got three. That's weird. How about an invalid operator like 9 equals 2? Okay, I got no response. And how about a dangerous operation like 7 divided by 0? Yep, I broke it with an arithmetic exception. That's a division by zero. You may want to execute these cases with a breakpoint to inspect what's going on in each case. For now, take a moment to look at the code. No measures are taken for any of the special situations I created at runtime. Those situations are an invalid input format, an invalid operator, and a runtime error. Now let me open a version of this program that errors out whenever a problematic situation is found…