1. Write your program, and make sure it compiles
2. Set a breakpoint in your code. Do this by clicking the cursor on the line that you want to set the breakpoint and then press the "set breakpoint" button. (You can also set a breakpoint using the right mouse button)
You may want to set the breakpoint at an early place in your code so that you can step through the whole program, or there may be a specific place where you want to start stepping through your program.
Note that it is possible to choose a line of code where Visual C++ can not stop. If this is the case it will automatically be moved down to the next valid line of code. (One place where Visual C++ does not seem to be able to stop is a declaration where you do not initialize the variable)
3. Now under the build menu choose "Rebuild All". This is necessary to force Visual C++ to recompile your code and add debugging information.
4. Now click the "go" button. The program will run until your first breakpoint.
Now that you've started the debugger what can you do?
The "step over" button allows you to execute the statement that the arrow is pointing at
The "step into" button executes the "sub-steps" that the statement the arrow is pointing at represents. If you are pointing at a function call, you will enter the function. This can be very confusing if you are pointing at a cin command and you go into the code for cin. To get back out of the function, push the "step out" button.
The "step out" button completes the running of the function you are in and takes you back to the next line of code after the function call
The "restart" button will start running your code again from the beginning
The "run to cursor" button runs your program up to the line where the cursor is flashing
The "stop debugging" button stops the debugger and puts you back into editing mode
The "quick watch" button allows you to check the value of a variable.
You can also force the system to let you watch the value of a variable as it changes by clicking under the word "name" in the bottom right hand corner of the screen and entering a variable name