Text only

How to create a simple c++ program in Visual C++

 

Click start->all programs->programming->Visual Studio .NET 2003->Microsoft Visual Studio .NET 2003

 

This will open Visual Studio

 

2. Click File->New->Project

 

This will begin to create a new project.

3. Select the project type as Visual C++. Select Win32 Project for the template type.

Be sure to change the location to U: or your thumb drive (usually F) so that your project is not "trapped" on the local hard disk of the PC you are using.

 

 4. A pop-up window will appear. Click on application settings

Click on console application. Do not fill the checkbox for Empty Project.

Click Finish.

 

5. Click File->Open->File. Browse to your project directory from the previous step.

This will allow you to edit the project’s default source file, which is project_name.cpp.

In this example, the file name is hw3.cpp

 

You will then see the blank file created by the project creator.

 

7. Replace the source code with your source code. Do NOT delete the #include “stdafx.h” or your program will not work. Here is a simple example.

 

#include "stdafx.h"

 

#include <iostream>

 

using namespace std;

 

int main()

{

    cout << "Hello World!" << endl;

 

    return 0;

}

 

8. Click Build->Build<yourproject>. In this case, the project is hw3

This will build your program. If it builds successfully, you will see 1 succeeded in the output window, as below.

9. To execute your program, click Debug->Start.

 You should see the output window briefly popup. If your program completed successfully, you will see a message that it exited with code 0, as below.

10. In order to keep the output window, use Debug->Start Without Debugging

The output window will then remain on the screen.

11. To save the output window. Select it, and the press Alt-PrintScreen. This will copy the active window to the clipboard. To save it, paste it into a file, such as a Microsoft Word file, by pressing Shift-Insert.

12. Enjoy!