Visual C 2012 Tutorial For Introduction PDF
Visual C 2012 Tutorial For Introduction PDF
1 Introduction
Suppose you have installed Visual C++ 2012 Express Edition. You
can launch Visual C++ from the Windows Start button by choosing
VS Express for Desktop. The Visual C++ 2012 Express user
interface appears, as shown in Figure 1.
Figure 1
The Visual C++ user interface is a single window that
performs editing, compiling, debugging, and running
programs.
1
3 Creating a Project
Figure 2
You need to create a project before creating programs.
2
Figure 3
Win32 Application Wizard creates a project for Win32
applications.
Choose
Empty
Figure 4
Win32 Application Settings window lets you set the application
type.
3
Solution
Explorer
shows
Figure 5
A project is created for C++ console applications.
After you create a project, you can create programs in it. Here
are the steps to create a C++ program for Listing 1.1:
4
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.
5
Figure 8
Welcome.cpp is created in the project.
Figure 9
The source code for Welcome.cpp is entered.
6
After you create a program, you can compile it. You may do so by
choosing Build, Compile, or press Ctrl+F7, or choose Compile in
the context menu for Welcome.cpp, as shown in Figure 10.
Figure 10
Choose the Compile command to compile the program.
To run the program, press Ctrl+F5. You will see the output
displayed in a DOS window, as shown in Figure 11.
Figure 11
The output is displayed in a DOS window.
NOTE:
<Side Remark: compile and run>
The Run command invokes the Compile command if the
program is not compiled or was modified after the
last compilation.
NOTE:
<Side Remark: one main function>
7
Each project can have only one file that contains a
main function. If you need to create another file
with a main function, you have two options:
Remove the current file that contains a main
function from the project by choosing Remove
from the context menu of the program, as shown
in Figure 12. (Note that you can add an
existing file to the project by choosing File,
Add Existing Item.)
Create a new project for the new program.
Figure 12
You can remove a file from a project.
***END NOTE
In Chapter 9, you will learn header files. You need to add the
header files in the Header Files node under the project node.
8
2. Choose Properties to display Project Properties dialog
box, as shown in Figure 14.
3. Choose General under C/C++ on the left column. Enter
c:\teacher in the Additional Include Directories field.
Figure 13
9
Figure 14
10