O'Reilly logo

SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

What Went Wrong?

This is one of the most feared problems a programmer must face. The program did something terribly wrong—so wrong that it behaved completely unexpectedly. How can you find out what happened?

In this case, you can use cout statements to find out where the program “died.” These statements provide a status report at the beginning of each step in the program. When a status report is not provided, you will know that the program stopped in the code just before that step.

To let these debugging statements show what is happening at each stage, the program will pause after each status report and require the user to enter a character.

Listing 4.3 shows the example with these debugging statements.

Listing 4.3. Example with Debugging Statements ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required