Introducing Microsoft Visual C++ V6.0

This tutorial is only meant to help you get started with the Microsfot Visual C++ tools, version 6.0.  This tutorial was first written in great haste, helpful comments will be appreciated.  Barbra Johnston't text C++ Programming Today comes with a copy of Microsoft Visual C++ tools, version 6.0 on CD-ROM that you can install on a home PC. 

The computers in UT212 do not allow students direct access to the C: drive, rather the S: drive is used.  To access applications, first open the local applications window. 

Start => Programs => Local Apps UT212

With the local appications window open, simply double click on the application icon.  For example, double clicking on the Windows Explorer icon starts Windows Explorer.  In working at home however, you may have to click the following before selecting a desired program.  Also replace references to S: with C: for your own hard drive. 

Start => Programs

Before starting Visual C++ for the first time, make a folder that you will work from.  If you are at home, double click the My Computer icon and double click to open the C: drive.  If you are at school, double click to open the Windows Explorer icon and navigate to open the S: drive and in the file area right click and select the following:

New => Folder
As soon as the new folder icon appears, enter the a new folder name that you will recognize and depress the enter key.  You can use your last name or nickname.  I'm using the name es115.  Start Visual C++, if you are in UT212, double click the icon in the local applications window.  At home, click on the Start button and make a selection similar to the following.  One the program opens, if the Tip of the Day window appears, click OK to close it. 
Start => Programs => Microsoft Visual C++ => Microsoft Visual C++

Visual C++ is 'project oriented' in that each program you write will be organized into a so called project.  Natually, the first thing to do is make a new project.  With the mouse, in the Visual C++ window click on:

File => New
In the pop-up window click the 'Projects' tab and in the left pane click 'Win32 Console Application'.  Enter AddTwo in the 'Project name' field and to the right of the 'Location' field click the browse button. 


New project file browser button

Use the Choose Directory pop-up window to navigate, to find the folder you made earlier, then click OK.  Examine the rest of the window and compare it to that below and then click OK. 

In the next window check the An empty project button and click Finish and in the final pop-up window click OK.  Next, create a new file.  In the Visual C++ window, select

File => New
In the pop-up window click the 'Files' tab and in the left pane click on 'C++ Source File' and in the File name field enter AddTwo.cpp so the window appears like that below.  Click OK.

Enter the following text into the new source code window.  Except for minor changes, this program is from section 1.1 of Johnston's text.  The '//' symbols form the start of a comment.  In this simple example, replace my name with yours.  Get into the habbit of inserting into the top of evey file you create, a comment that includes the file name, your name, and a brief decription of what the program does.

// AddTwo.cpp - Jonathan Hill
// Add two numbers that a user enters

#include <iostream.h>

int main()
{
  int A,B,C;

  cout << "\n Please enter two numbers ";
  cin >> A >> B;

  C = A + B;

  cout << "\n The sum is " << C << "\n";

  return 0;
}
Once entered, save the file and build the executable. 
File => Save
Build => Build Addtwo.exe
If you encounter an error, go back, fix it, save and rebuild.  Many time a single typographical error can introduce many errors.  In reviewing errors, always start with the first error rather than the last one.  Assuming that all goes well, execute the program. 
Build => Execute Addtwo.exe
If the Microsoft end user license reminder window appears, click OK to close it and then click to raise the execution window.  the output will look similar to the following:

 Please enter two numbers 2 3

 The sum is 5
 To exit, depress the 'Enter' key
Press any key to continue

Congratulations, you have just executed your first program using Microsoft Visual C++ version 6.0.  The actual executable file 'AddTwo.exe' is in the subfolder named Debug.  The next step is learning how to save and close, and later reopen a project.  The saving and closing part is easy.  With the mouse select the following.

File => Save
File => Save Workspace
File => Exit

In the future when you want to reopen the project, you can use windows to navigate to the file and double click on the .dsw workspace file.  This action opens Visual C++ with the corresponding project in the state that you previously saved it in.  Alternatively, you can open Visual C++ and then open an existing workspace.

File => Open Workspace
Next use the popup window to find and hightlight the corresponding .dsw file.  The, click OK.  Briefly consider how to bring code that you wrote at home, to school.  If you only bring a .cpp file to school, you will first have to create a new project using the method described above.  If you also bring the corresponding .dsp and .dsw files, you can start up the project in Visual C++, just by clicking on the .dsw file.  Visual C++ automatically regenerates the other files it uses.


This tutorial is written for the engineering students at the University of Hartford.  Copyright is reserved by the author, but copies of this document may be made for educational use as-is, provided that this statement remains attached.  The author welcomes corrections, comments, and constructive criticism. 
Original Author: Jonathan Hill jmhill@hartford.edu
Copyright Date: Wed Feb 5 00:38:59 EST 2003
Last revised: Wed Feb 5 00:38:59 EST 2003