1. Home
  2. Computing & Technology
  3. C / C++ / C#

C++ Tutorial - Lesson One Learning How to Compile With Visual C++ 2005

By , About.com Guide

1 of 8

Learning Visual C++ 2005

Screenshot of New Target Screen
Learning a new piece of software can be daunting, but this tutorial will show you how to create a new project, add source code files then build and run your program.

Load Visual C++ 2005

Start by loading the Visual C++ IDE. You can also see how to do this with Visual C++ or Turbo C++ Explorer.

From the File menu, click New and select Project. Select Win 32 on the Project Types tree. In the name box, enter example1. You can change the location to wherever you want to store the examples. It defaults to a folder within Documents and Settings. This folder holds the source code and project files. If you want a new directory leave the Create directory for solution checkbox ticked.

Click OK. You will now see the Win 32 Application Wizard. You can press Finish or click Next to see the Application Settings. For example 1 we can keep the default settings.

Now type in a couple of lines so you end up with this. Press Ctrl + s (ie Hold the ctrl key down and press the s key) and this will save the file. You can also click File, Save example1.cpp or click the single floppy disk image just below and between the View and Project menu commands.

// example1.cpp : main project file.
#include "stdafx.h"
#include <iostream>

using namespace std;

int main(void)
{
cout << "Hello World";
return 0;
}
Press the F7 and this will compile. Before you run it, click the line
return 0;
and press the F9 Key. You can run it by pressing F5. It will open a console window and output "Hello World". Press F5 and it will continue running and exit. Without the Break Point, it would just open the Windows, print Hello World and then close too fast to notice.

We'll use these same settings for all the future lessons in the C++ tutorials so make a note of them.

On the next page : A line by line breakdown of Example 1.

Explore C / C++ / C#
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. C / C++ / C#
  4. C++
  5. Learn C++ Programming
  6. C++ Tutorial - Lesson One Learning How to Compile With Visual C++ 2005 Express Edition>

©2009 About.com, a part of The New York Times Company.

All rights reserved.