Stepping Through the Code

   

The application example for this scenario accepts a date passed from the command line and converts it to a Julian calendar date. The application used in this scenario was built in Creating a Console. If you’d like to create this project to complete the following exercises, do so now.

You have entered a date for conversion, stopped on a breakpoint you’ve set, and used the debug windows to examine some of your program’s variables. You have an idea of what the problem may be, but you’d like to step through the statements of your code to get a better understanding of what’s really happening. The following procedure shows you how to trace through your program’s execution.

To step through your program when in break mode

  1. Place the cursor in the margin next on the line of code where you would like to begin stepping through your code.

    Tip   Choose a line that will be executed before the application ends.

  2. If you are following the scenario for debugging a Console application, place the cursor next to the following code:
    for(int nCount=1; nCount < m_nMonth; nCount++)
    
  3. Click in the margin.

    A red dot appears in the margin indicating the line on which the breakpoint was set.

  4. Press F5 and the debugger runs your application and breaks on your new breakpoint.

    The yellow arrow in the margin points to the next instruction to be processed.

  5. Continue to step through your program by pressing F11, paying attention to the line of code being executed and information displayed in any open debugging windows.

    In the open debug windows, values for member variables display in red whenever these values change. If you’re following the debugging scenario for a Console application, continue stepping through your application’s source code until the values for m_nDayOfYear and nCount change to red in the open debug windows.

    For more information about stepping through your program’s code with the debugger, see Stepping Through Code to Trace Execution.

To terminate the debugging session

When your program enters break mode, you may want to set another breakpoint or examine one or more Debug Windows to view the values of your program’s member variables.

See Basic Debugging Procedures for additional information on using the features of the integrated debugger.