Beginning Visual CPP 2005 Express Part 3 - Online Article

Creating CLR Console Application

To create a new Project

Step 1: On the File menu, point to New, and then click Project...

Image1

Step 2: In the Project Types area, click CLR then in the Visual Studio installed templates pane, click CLR Console Application. Type the Project name as CLRConcoleapp.

Image2

Step 3: Add a source code in CLRConsoleapp.cpp with in main() module.

Console::WriteLine(L"Welcome to VC++ 2005 Express Edition");

Image3

To Build the application

Click on build->build solution

Image4

Output window will show the compiled solution.

Image5

To Debug the application

Click to Debug->Start without Debugging

Image6

Now, Console Application exe appears

Image7

Creating WIN32 Console Application

To create a new project

1. On the File menu, point to New, and then click Project....

Image8

2. In the Project Types area, click Win32, then in the Visual Studio installed templates pane, click Win32 Console Application.

Image9

3. Type consoleapp as project name. When you create a new project, Visual Studio places the project in a solution. Accept the default name for the solution, which by default is the same name as the project. You can accept the default location, type in a different location, or browse to a directory where you want to save the project.

4. From the Overview page of the Win32 Application Wizard dialog, press Next.

5. Select the Empty Project setting and click Finish.

Image10

You now have a project with no source code files.

Using Solution Explorer

Solution Explorer allows you to work with files and other resources in your solution. In this step, you add a class to the project and Visual Studio adds the .h and .cpp files to your project. You then add a new source code file to the project for the main program that tests the class.

To add a class to a project

1. If the Solution Explorer window is not visible, on the View menu click Solution Explorer.

Image11

2. Right-click on the Source Files folder in Solution Explorer and point to Add, then click Item.

Image12

In the Visual C++ category, click to code and click C++ file(.cpp) Class in the Visual Studio installed templates area. Name the code as Welcome. Click Add.

3. A blank code window appears. Type the following code in the code window

#include<iostream>
using namespace std;
int main()
{
	char name[64];
	cout<<"please enter your name";
	cin>>name;
	cout<<endl<<endl;
	cout<<name<<" says, 'Hello! Welcome to VC++ ' "<<endl<<endl;
	return(0);
} 

To Build the application

1. Click on build->build solution

2. Output window will show the compiled solution.

Image13

To Debug the application

1. Click to Debug->Start without

2. Debugging Console Application exe appears.

Image14

To Run

1. Type a name.

2. Let us say "SARA" and press enter. Following output is generated,

SARA says, 'Hello! Welcome to VC++ '

Image15

About the Author:

No further information.




Comments

No comment yet. Be the first to post a comment.