Transcript
Page 1: ---------------------------------------------------------- · Babylon University- College of Information Technology- Software Department. Page 3 4. Then you must choose Console Application

Babylon University- College of Information Technology- Software Department. Page 1

How to create console application in visual studio 2012

In this lecture you will learn How to:

1. Create console app in visual studio 2012.

2. Build the console app.

3. Debug the console app.

----------------------------------------------------------------------------

1. Create Simple Application

Steps To create a console app:

Step1: You first must create a project and solution by the following steps:

1. On the menu bar, choose File, New, and Project.

Page 2: ---------------------------------------------------------- · Babylon University- College of Information Technology- Software Department. Page 3 4. Then you must choose Console Application

Babylon University- College of Information Technology- Software Department. Page 2

2. In the Visual C++ category, choose the Win32 Console Application template, and then name

the project HelloWorld.

3. When the Win32 Application Wizard appears, choose the next button.

Page 3: ---------------------------------------------------------- · Babylon University- College of Information Technology- Software Department. Page 3 4. Then you must choose Console Application

Babylon University- College of Information Technology- Software Department. Page 3

4. Then you must choose Console Application and make sure to check empty project, then

choose the Finish button.

The HelloWorld project and solution, with the basic files for a Win32 console app, are created

and automatically loaded into Solution Explorer.

Page 4: ---------------------------------------------------------- · Babylon University- College of Information Technology- Software Department. Page 3 4. Then you must choose Console Application

Babylon University- College of Information Technology- Software Department. Page 4

Step2: you must create C++ file with extension (.cpp), for example source.cpp by the

following:

1. On the Source files, choose Add, New Item.

2. In the visual c++ category, choose the C++ File (.C++) template, and then name the file Source,

then choose the Add button.

Page 5: ---------------------------------------------------------- · Babylon University- College of Information Technology- Software Department. Page 3 4. Then you must choose Console Application

Babylon University- College of Information Technology- Software Department. Page 5

The source.cpp file is appear in Solution Explorer and opened in the code editor with no code.

Now you can write cpp code in the source.cpp file as in the figure:

Page 6: ---------------------------------------------------------- · Babylon University- College of Information Technology- Software Department. Page 3 4. Then you must choose Console Application

Babylon University- College of Information Technology- Software Department. Page 6

Debug and Test the application

To see the output of the program, you must do two steps after save it using SAVE ALL bottun : i

First: Build the application as in the figure:

If there is no error in the code, Build Succeeded will appear on the bottom also you must

see (Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped) in last line in

output window, as in the next figure:

Page 7: ---------------------------------------------------------- · Babylon University- College of Information Technology- Software Department. Page 3 4. Then you must choose Console Application

Babylon University- College of Information Technology- Software Department. Page 7

Second: Now, you can debug HelloWorld application by Choose the F5 key to start debugging or click

on icon as in the next figure:

The debugger starts, and a console window appears showing the Hello World.


Top Related