









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Material Type: Project; Professor: Liang; Class: INTRO PROGRAMMING PRINCIPLES; Subject: Computer Science; University: Armstrong Atlantic State University; Term: Unknown 2005;
Typology: Study Guides, Projects, Research
1 / 17
This page cannot be seen from the preview
Don't miss anything!
For Introduction to C++ Programming By Y. Daniel Liang
1 Introduction
Visual C++ is a component of Microsoft Visual Studio .NET for developing C++ programs. A free version named Visual C++ 2005 Express Edition is included in the book’s Companion CR-ROM. This section introduces how to create a project, create a program, compile and run the program.
2 Getting Started with Visual C++
Visual C++ is easy to install. If you need help on installation, please refer to V C++ Tutorial in the supplements.
Suppose you have installed Visual C++ 2005 Express Edition. You can launch VC++ from Windows Start button by choosing All Programs , Visual C++ 2005 Express Edition , Microsoft Visual C++ 2005 Express Edition. The Visual C++ 2005 Express Edition user interface appears, as shown in Figure 1.
Figure 1
The VC++ user interface is a single window that performs editing, compiling, debugging, and running programs.
3 Creating a Project
To create C++ programs in VC++, you have to first create a project. A project is like a holder that ties all the files together. Here are the steps to create a project:
Figure 2 You need to create a project before creating programs.
Figure 5 A project is created for C++ console applications.
4 Creating a C++ Program
After you created a project, you can create programs in the project. Here are the steps to create a C++ program for Listing 1.1:
Solution explorer shows
Figure 6 You can open the Add New Item window from the project’s context menu.
Figure 7 You can specify the file type, name, and location to create a file.
Figure 10 Choose the Compile command to compile the program.
6 Running a C++ Program
To run the program, choose Debug , Start Without Debugging , or press Ctrl+F5. You will see a dialog box, as shown in Figure 11(a). Click Yes to continue. You will see the output is displayed in a DOS window, as shown in Figure 11(b).
(a) (b)
Figure 11 The output is displayed in a DOS window.
NOTE:
NOTE:
Figure 12 You can remove a file from a project.
Figure 13
A breakpoint is set in ShowCurrentTime.cpp.
7.2 Starting the Debugger
To start debugging, set a break point at the first line in the main function and choose Debug , Start (or F5). If the program compiles without problems, debugging starts. You will see several small windows appearing at the bottom, as shown in Figure 14.
Figure 14
The debugging windows appear in the IDE.
The window on the left is called the variable window with three tabs at the bottom (Autos, Locals, and Watch). (If these windows do not appear, choose Debug , Windows to open these windows.)
Figure 16
The Locals window displays all variables in the block.
Figure 17
The Watchs window displays the variables you want to watch for.
7.3 Controlling Program Execution
The program pauses at a line called the current execution point. This line is highlighted and has a yellow arrow to the left. The execution point marks the next line of source code to be executed by the debugger.
When the program pauses at the execution point, you can issue debugging commands to control the execution of the program. You also can inspect or modify the values of variables in the program.
When VC++ is in the debugging mode, the Debug menu contains the debugging commands (see Figure 18). Most of the commands also appear in the toolbar under the message pane. The toolbar contains additional commands that are not in the Run menu. Here are the commands for controlling program execution:
If you need to include a header file from a directory that is different from the program directory, you need to add the directory in the project properties. For example, suppose Test.cpp needs to include Temp.h and Temp.h is in c:\teacher. Follow the steps below to add c:\teacher in the project property dialog box:
Figure 19
You can customize project properties in VC++.
Figure 20
C:\teacher is added in the path.