Turbo C++ provides many useful debugging features. The debugging features of turbo C++ are available in Debug menu. Some important debugging features of turbo C++ are as follows:
A program may not execute even if it has been compiled successfully. The debugger provides the facility to find errors by executing one line of the program at one point. It enables the programmer to detect the exact place of error. The following procedure is used to execute one step at a time with single stepping:
Select Run > Trace Into OR press F7 key.
The watch or watch expression is used to check the value of variable as the program executes. It indicates how the values of variables change during program execution. It is normally used in combination with single stepping.
The following procedure is used to use watch expression:
- Place the cursor on the variable whose value is to be checked.
- Select Debug>Watches. A submenu will appear.
- Select ADD Watch from the submenu. Or press CTRL + F7. A dialog box will appear. The selected variable will appear in Watch expression field.
- Click OK or press enter. A new window will appear indicating that the selected symbol is undefined.
- Select Run > Trace Into Or press F7 to execute single stepping. The values of the selected variable will appear in watch window.
A breakpoint is used to mark a part of program where program execution will stop. The program executes all statements up to the break point and then stops. The user can check the values of a variable at this point by using Watch window by single stepping the remaining part of the program.
The following procedure is used to insert a breakpoint in the program.
- Place the cursor on the line on which the breakpoint is to be inserted.
- Select Debug > Toggle breakpoint Or press CTRL + F8. The breakpoint will be inserted and the line will be highlighted.
The evaluate/Modify window is used to change the value of variable during program execution. It can be useful if the user is single stepping the program and wants to change the value of a certain variable. The following procedure is used to evaluate/modify window:
- Select Debug > Evaluate/modify. A new window will appear with three fields.
- Enter the name of the variable whose value is to be modified in Expression field.
- Enter the new value for the variable in New Value field. The value of the third field Result will also change automatically.