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.