computer science i how to configure visual studio.net 2003 for c++ colin goble

7
Computer Science I How to Configure Visual Studio.NET 2003 for C++ Colin Goble

Upload: april-allison

Post on 02-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computer Science I How to Configure Visual Studio.NET 2003 for C++ Colin Goble

Computer Science IHow to Configure

Visual Studio.NET 2003for C++

Colin Goble

Page 2: Computer Science I How to Configure Visual Studio.NET 2003 for C++ Colin Goble

Starting Visual Studio• Using Windows Explorer, create a folder on your hard

drive to contain the projects you will be working on this term. I would suggest C:\CS161 for want of anything better.

• Open Microsoft Visual Studio.NET 2003• Click New Project• Select Visual C++ Projects and Win32 Console Project

– It is VERY important you choose these exact settings. For example, do not choose Console Application (.Net) or Win32 Project by mistake

• Enter a Name for your project. I recommend you choose a suitable name, such as HelloWorld or Horoscope, as appropriate. I also recommend you not use embedded spaces in your names.

• Enter the Location for your project. This will be C:\CS161 if you did as I suggested in step 1.

• Click OK.

Page 3: Computer Science I How to Configure Visual Studio.NET 2003 for C++ Colin Goble

Win32 Application Wizard

• Important: On the next screen, select the Application Settings tab, and choose Empty Project and Console App.

• Click Finish• Your project has been created in a subfolder of

C:\CS161. The subfolder name is the same as the project name. You can explore this folder to see the various files Visual Studio has created.

Page 4: Computer Science I How to Configure Visual Studio.NET 2003 for C++ Colin Goble

Entering your C++ Program

• In the Solution Explorer panel of Visual Studio (top right), right click on Source Files, and select Add New Item

• Choose Visual C++, C++ File (.cpp)• Enter a suitable name for your source file (e.g.

helloworld). I recommend you not use embedded spaces in your name.

• Check that the Location refers to your project folder.

• Click Open

Page 5: Computer Science I How to Configure Visual Studio.NET 2003 for C++ Colin Goble

Click on your new source file in Solution Explorer and enter your program in the main edit window on the left

// This is the Hello World program (HelloWorld.cpp)// Written by: Colin Goble// Date: 16 Sep 2004// Sources: None

// The next two lines are standard boilerplate// you need in front of virtually every C++ program.

#include <iostream>using namespace std;

int main (){

cout << "Hello World" << endl;return 0;

}

Page 6: Computer Science I How to Configure Visual Studio.NET 2003 for C++ Colin Goble

Running your Program

• First you must build (compile and link) your application.– On the menu bar click Build followed by Build Solution

(cntl-shift-B)– Make sure there are no errors

• To run your application– On the menu bar click Debug followed by Start

Without Debugging (control-F5)

• Confirm your program outputs “Hello World”

Page 7: Computer Science I How to Configure Visual Studio.NET 2003 for C++ Colin Goble

Editing and Bug Fixing

• If there are errors of any kind, you must correct the errors by editing the text in the main edit window, and rebuilding and rerunning your application.

• You must repeat this cycle until everything is correct and to your satisfaction.

• Close Visual Studio.• To reopen your project at a later date, open

Visual Studio, and choose Recent Projects from the File menu.