Software Design Using C++

An Online Book

Old Version -- No Longer Maintained

Please Refer to the New Version

Debugger Lab

The purpose of this lab is to acquaint you with workspaces and projects in MS Developer Studio as well as to try out the debugger.

Starting Out

Start your PC, supplying your ID and password when asked. Start up MS Developer Studio.

Create a Workspace

Create a new workspace on your M drive, perhaps named using the name of the course. (Skip this if you already have an appropriate workspace.)

Create a Project

Create a new project, named lab1, of type Win32 Console Application. Be sure that you tell it to add this project to your current workspace.

Create a Source File

Create a new C++ source file, named reverse, and be sure that the "add to project" box is checked.

Copy Existing Code

We will insert code into the reverse.cpp file from this Web page. The file to insert is bad.cpp. Follow the link just shown. Then use File, Save As to save a copy of this program in the directory for your project. In Developer Studio use Insert, File as Text to insert a copy of bad.cpp into your reverse.cpp file. Save the file by using File, Save.

A different way to copy the code into the reverse.cpp file is to drag the mouse over the bad.cpp code to highlight it. Use Edit, Copy. Then exit from your web browser and click inside the empty reverse.cpp file in the editor in Developer Studio. Use Edit, Paste. Then use File, Save to save the file.

Compile the Program

Use Build, Rebuild all to try to compile the program. If you get a syntax error, double click on the error message to find the location in the code where the problem was detected. Fix the syntax errors and rebuild.

Run and Debug the Program

Once the program compiles without errors, run the program. The output will be incorrect. Use the debugger to step through the program line by line to find the problem. (Remember to use Step Into if you want to go inside of a function.) Once you locate the logic error(s) in the program, fix them. (Check with the instructor to see if your fix is a good one.) Run the program to be sure that the output is now correct.

Save Your Work

Be sure that you have saved your corrected reverse.cpp file before you exit from the Developer Studio.

Check Your Solution

You can check your solution by comparing it with the file better.cpp, a working version of the bad.cpp program.

Finish Up

Be sure to exit from Developer Studio and to properly shut down your computer when you are finished. (Use Start, Shutdown, Yes.)


Related item: Using Microsoft Visual C++ 5.0

Back to the main Software Design Page