CS210 Lab: Introduction to Visual C++--Debugger Tips
In this lab example, we used the Step Over to examine the
loop. What will happen if we use Step In? Well,
Step In will examine the program one line a time and it
will go into every function if a function is called.
Therefore, if we use Step In to examine the loop with the cout and cin
would have stepped into the cout and cin
system functions. this is not what we want. So when you debug
your program, whenever you encounter the system functions, which
do not need to be debugged, use Step Over instead of Step In.
This is one of the tricky part of the debugging process which
could get you into trouble. You will get into even more
troubles if you do not know what you are doing. The
following are some surprises, how they happened, and how to deal
- Problem one: The
console window disappears quickly after it appears.
window is still there. You'll find it from the bottom of your
- Problem two: A "Find
File" dialog box pops up.
probably pressed Step Into
when you should have pressed over , and you
entered some function you didn't expect (such as a predefined
library function). This might happen especially if you press Step
the arrow points to an input or output statement (the
<< and >> operators are actually
predefined functions). (It can also happen if you press Step Over beyond
the point where your program ends.) VC++ is asking for a file
containing the source code for this function. Select
Debug --> Step Out)
to finish executing the library function and get execution
back to your source code.
- Problem three: My source
code has been replaced with weird stuff, with numbers in the left-hand
column and words like "push" and "mov."
happens for the same reasons as above: you probably entered a
library function with
(should have used ).
This is the assembly code version of
the function. Select File | Close to get back to your
source code window, then press to finish
executing the library function and get execution back to your
If all else fails, you can always select Debug --> Restart
to start your program over again, or select Debug --> Stop
Debugging to quit execution of your program and stop
Back to the Introduction to Visual C++ Lab click
Copyright: Department of Computer Science, University of Regina.