CSC 160 - Visual C++ Debugging Quick Reference

An introduction to C++ debugging techniques using Microsoft Visual C++, Version 6.0.

Printing debugging information

Inserting debugging messages into your C++ code is an easy way to validate the correctness of your program. Most common uses are:

Using the debugger

Visual C++ provides facilities for making debugging C++ program easier. Once starting the debugger, you can execute your program one line at a time, or execute until breakpoints that you specify are reached. The main window will show you the current line of code to be executed. Other windows at the bottom of the screen can be used to see the value of variables.

Menu item Description
Build/Start Debug/Go Start the debugger
Build/Start Debug/Step Into Start the debugger, stop at the first line
Debug/Stop Debugging Stop the debugger, stops execution of program
Debug/Step Over Execute the next line of code, step over functions
Debug/Step Into Execute the next line of code, push into function call, if any
Debug/Step Out Pop out of the function you are currently in, if any
Debug/Run to Cursor Execute program until reaching line at cursor
Insert/Remove Breakpoint

(right mouse click on line)

Insert a new breakpoint or remove an existing one at that line
View/Debug Windows/Variables Shows the value of local variables in a bottom window
Quick Watch

(right click on variable)

Shows the value of that variable

When inputting values in the console, the debugger may wait for you to enter a value before returning control to you.

Step over library functions; it's rarely useful to see them execute. If you do this accidentally, then step out of the function until you reach your own code.