Visual C++ Introductory Edition Guide
by Feihong Hsu


At the request of several students, we have decided to post some information on the course page about how to use the Microsoft Visual C++ Introductory Edition that comes with your Absolute C++ book.

IMPORTANT NOTE:  The class policy regarding programs has NOT changed.  You must still get your programs to run on the Sun workstations in 2250 SEL, or you will get 0 points for your program.  With this guide, however, you will have a much better chance of getting it to run on the first try.


STEP 1:  Installing Visual C++

The setup program for VC++ will automatically run once you insert the CD into your CD drive.  You can simply select the typical installation.  However, be warned that this installation will take up over 100 MB on your hard drive.  You will not need the environment variables to be set up, so do not select that option.  After VC++ is installed, it will ask you to install the VC++ documentation.  We highly recommend that you do so, as it includes a lot of info on standard C++.


STEP 2:  Setting Up Your Project

Once installation has completed, run Microsoft Visual C++.  Immediately after the splash screen (with the pretty picture on it), the Tip of the Day will come up.  Just hit the Close button (you can read it if you're interested).

From the menu, select File: New.  Because we will not write any GUI (Graphical User Interface) applications, you should select Win32 Console Application.  You must also type the Project name in the text box.  In the example image below, we have named our project "Practice".  You may also want to change the location where your project will be created.  Click the OK button.

Picture of the New dialog

On the next screen, you will be given a set of choices.  Choose "A simple application".  Click the Finish button, then click OK on the next dialog.  Your project will now be created for you.

Picture of the Step 1 dialog

Now that your project is open, you need to adjust some settings.  Click on the File View tab in the left-most window, then click on the "+" symbol in front of "Practice files".  Do the same for "Source Files" (after clicking on the "+" symbol, it will turn into a "-" symbol.  Right-click on the "Practice.cpp" file (in general, this file will have the same name as your project).  Select Settings...  

A picture of your project

A dialog called Project Settings will appear.  Under the C/C++ tab, choose Precompiled Headers in the Category combo box.  Select the first radio button, "Not using precompiled headers".  Click the OK button.

A picture of the project settings


STEP 3:  Write a "Hello World" program

Double-click on "Practice.cpp".  Comment out the line that contains #include "stdafx.h".  Under it, type these lines:

#include <iostream>
using namespace std;


Inside the main function, type:

cout << "Hello world!\n";

A picture of the source code you need to edit

Press the F7 key to compile your project, or else select Build: Build Practice.exe from the menu.  A small window will appear at the bottom, informing you of how the build process is going.  At the end of the build, you should see that there are 0 errors and 0 warnings.  Press Ctrl+F5 or else select Build: Execute Practice.exe.  Your program will now run inside a DOS window.  Press the Enter key to terminate your program.


STEP 4:  Testing "Hello World" on the Suns

Now you need to transfer your Practice.cpp file to the Sun workstations to see if it will actually compile where it really counts.  Because Windows and UNIX text files are slightly different, you need to use an FTP program.  In this example I will be using WS_FTP LE from Ipswitch, which is free for educational purposes (download it here).  When installing WS_FTP, you MUST choose the options that indicate that you are a student, that you will use it at school, and that you will use it for academic purposes.  

Once you start WS_FTP you will be presented with the Session Properties dialog.  Click the New button, then fill in the text boxes as follows (enter text without quotes):
  1. "Bert" for the Profile Name
  2. "bert.cs.uic.edu" for Host Name/Address
  3. "Automatic detect" for Host Type (the default)
  4. Your user id for User ID
Click the OK button.

A picture of the WS_FTP Session Properties dialog

After you are logged into the server, you will see a dialog with two panes.  The left pane, labelled "Local System", shows the files on your hard drive.  The right pane, labelled "Remote Site", shows the files on your CS account.  First, mark the "ASCII" radio button below the Local System" pane.  Next, you must go to where your "Practice.cpp" file is stored.  Click on the ChgDir button and type in the path of the folder where "Practice.cpp" resides (for example, "E:\Documents and Settings\Feihong\Desktop\Visual C++").  An alternative is to navigate to the folder by double-clicking on directories and the "Up" symbol (which takes you up to the parent directory).  After you have found "Practice.cpp", select it and press the Right Arrow button (looks like -->).  You should be able to see "Practice.cpp" listed inside the "Remote Site" pane (you may need to scroll down to see it).  Finally, click the Exit button to close the FTP session and exit WS_FTP.

A picture of the two panes in WS_FTP

Alright, time to telnet into your CS account (or you could walk to SEL, but we think you should try this way first).  Click on the Start Menu, and select Run...  Inside the text box, type:

telnet bert.cs.uic.edu

Then click the OK button.  You will be prompted for your user id and password; enter them as you would if you were logging directly onto a Sun workstation.

A picture of the Run dialog, accessed from the Start Menu

Once you see your command prompt, type

g++ Practice.cpp    <ENTER>
a.out               <ENTER>


You should see "Hello World!" printed on your screen.

NOTE:  If g++ does not work, make sure to set your LD_LIBRARY_PATH environment variable correctly.  Also, make sure Practice.cpp is in the current directly by using ls.

A picture of the telnet session


CONCLUSION

Congratulations!  You can now develop C++ applications using Visual C++, transfer your code to a Sun workstation, and remotely compile it using telnet.  Just remember, every time you start a new project in Visual C++, you will have to repeat Steps 1 and 2.  

When porting your code from Windows to the Suns, watch out for this annoying error:  

#include <iostream.h>   // Notice how there's a .h at the end!!!
//using namespace std;  // Notice how this line has been commented out!!!


Your code will compile fine in Visual C++, but fail miserably on the Sun workstations.

The information presented in this guide was a very brief intro to Visual C++.  It is actually quite a good C++ IDE (Integrated Development Environment), with a lot of nice features.  You should explore the help files on your own; of particular interest is the section on how to debug your programs step-by-step.  Note that we will not spend any lecture or discussion time discussing how to perform tasks in Visual C++.

You should now be able to edit your source code in Visual C++ Introductory Edition.  If for some reason the previous steps did not work for you, you can contact Feihong at fhsu@cs.uic.edu, or see him during his office hours in 2250 SEL.