![]() Step-Into and Step-Out: To debug a function, you need to use "Step-Into" to step into the first statement of the function. Explore the features provided by the debuggers. Important: I can's stress more that mastering the use of debugger is crucial in programming. Always terminate your current debugging session using "Stop" or "Continue" till the end of the program. ![]() You could set a breakpoint at the statement immediately outside the loop (e.g., Line 12 of the above program), and issue "Continue" to complete the loop.Īlternatively, you can place the cursor on a particular line, right-click and select "Run-To-Cursor" to resume execution up to this line. Single-stepping thru a loop with a large count is time-consuming. The "Continue" resumes the program execution, up to the next breakpoint, or till the end of the program. To set a breakpoint on a particular line, click the left-margin of that line (or select "Toggle Breakpoint (F5)" from "Debug" menu). Single-stepping thru the program and watching the values of the variables and the outputs produced is the ultimate mean in debugging programs - because it is exactly how the computer runs your program! Step 4: Breakpoint, Run-To-Cursor, Continue and StopĪs mentioned, a breakpoint suspends program execution and let you examine the internal states of the program. ![]() At each of the step, you could examine the internal state of your program, such as the value of the variables (in the "Watches" pane), the outputs produced by your program (in the console), etc. (You could also do it from the "Debug" menu.)Ĭlick the "Next line" button on the "Debug" toolbar to single-step thru your program. Step 3: Single-Step and Watch the Variables and OutputsĬlick the "Debugging Windows" button on the "Debug" toolbar and select "Watches" to enable the "Watch" pane. An yellow arrow (as shown in the diagram) appears and points at the main(), indicating this is the next statement to be executed. The program begins execution but suspends its execution at the breakpoint, i.e., main(). Step 2: Start Debuggingįrom "Debug" menu, select "Start (F8)". A breakpoint suspends program execution for you to examine the internal states. A red circle appears indicating a breakpoint has been set at that line. Set an initial breakpoint at main() function by clicking on the "left-margin" (right-side of the line number) of the line containing main(). Let's use the graphic debugger to debug the program. Run the program and observe the output produced: Int factorial = 1 // Initialize the product to 1Ĭout << "The Factorial of " << n << " is " << factorial << endl
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |