Using the Microsoft Visual C++ 6.0 IDE

Yosef Mendelsohn


Please note that the web version of this document is optimized for Microsoft’s Internet Explorer.  If you do not have IE, you may download this zipped file containing the text document (in Microsoft Word 97 format) and associated graphics.  The Word version does not include the videos.  (Click here for a tutorial on using Winzip)


A tourist in New York City was hopelessly lost and late for the evening’s symphony performance at the famed Carnegie Hall.  Looking about frantically he spotted a taxi driver stopped at a red light.  He ran over to the car and yelled at the driver:

“Hey, how do you get to Carnegie Hall?”

To which the wise driver shook his head, and replied:

“Practice, man.  Practice.”



From English to Gibberish:  Compiling your Code

For languages such as Java or C++, your code must be compiled before the computer will be able to execute (run) it. 




Students taking introductory courses in certain programming languages such as C++ or Java are faced with an added step to their work, namely, compilation.  To compile a program means to convert the code that the programmer has typed (called source code), into information that the computer can actually understand (object code).  Most people have little interest in ever seeing object code, and the more fortunate among us never will.  There are a number of reasons for the added overhead of compilation some of which will be described shortly.  For the moment, suffice it to say that the step of compiling your source code is a necessary evil which turns out to be quite useful. 


As languages such as C++ have evolved, many of them have become more English-like in their syntax and structure.  Further, they have often reached a point where a procedure that might take several hundred lines of code in machine language can be accomplished in just one or two lines of, say, C++.  The compiler takes care of this “translation”.  Compiling code also increases its efficiency so that the program runs faster.  Lastly, every compiler you are likely to encounter will also include a component that catches errors in your code and brings them to your attention. 

A Compiler by any other name…

Because compiling is an integral part of the programming process, software publishers have produced compilers that do more than simply compile.  For example, applications such as Microsoft’s Visual C++ or Borland’s Turbo C++ include (among other things),  a text editor (for typing the code), a debugger (for fixing the broken parts), and of course, the compiler itself.  For this reason, some people like to call these applications ‘Integrated Development Environments’ (IDEs) rather than simply ‘compilers’.  For simplicity’s sake, however, the general trend is to refer to Visual C++ as ‘the compiler’. 


As these development environments have become more advanced their features have been improved accordingly.  For example, you will soon notice that when you enter text into the Visual C++ text editor, various key words are printed in different colors.  Also, many of the indentations common to programming style are done automatically and are later un-indented when appropriate.  You will notice other features as you gain more experience with the environment. 

Because many other features have been built around the compiler, Visual C++   is more aptly (and maybe pretentiously) called an ‘integrated development environment’ (IDE) rather than a compiler.






Familiarity breeds contempt content

The downside to all of this is that learning to use one of these IDEs can be a bit of a bear.  The following primer will attempt to guide you through the basics of using the Microsoft Visual C++  IDE.   



And it begins.

When you first open the application, you will be faced with the following screen (or something similar to it).  The key windows have been labeled:


Now the first step is to create a new ‘workspace’ for yourself.  A workspace may contain multiple ‘projects’.  However, because we will not use this feature, the terms may be interchanged.  For consistency, we will stick with the term ‘workspace’. 


When you are confronted with the following steps for the first time, you may find the procedure a bit complex.   But rest assured that after the first few times, you will whip through the procedure in seconds. 


Create a new workspace:

  1. Click on File, New.  The following dialogue will appear:
  2. You will then choose (click) Win32 Console Application.  This means that we are not creating a fully-featured Windows application, but rather a boring old DOS program.  Believe me, for now you’ll be much happier for it. 
  3. Before clicking on ‘OK’ you will have to give your project a name.  Notice that just below the ‘Project Name’ field is a field called ‘Location’.  This field is the default location where your project will be placed.  So if in the location box you (or someone else) has specified ‘c:\temp’, then that is exactly where your project will be placed. 
  4. Click ‘OK’ , and then ‘Finish’.  The program will confirm your choices (which admittedly are rather minimal at this point).   Click on ‘OK’ to confirm.


You will now be faced with the following:

Visual C++ IDE after creating a new workspace



Notice that the name of your project is visible in the workspace window to the left. 


The last procedure was preparation for your workspace.  You are now ready to begin writing some code.  The idea here is to create a new file, and add it to your already existing workspace. 


Adding a file to a workspace:



  1. Click on File, New.  A dialogue box opens.  You will notice that it is very similar to the dialogue for creating a new workspace.  The difference is that the tab (at the top) for ‘Files’ is currently selected, rather than the tab for ‘Projects’. 
  2. The only kind of file you will work with in this course is the ‘C++ Source File’.  Choose that file.  But don’t click OK yet. 
  3. You must first give the file a name.  Unlike the traditional method of creating a new file (say, in your word processor) and then only having to name it when you first save, MSVC forces you to specify a name prior to creating the new file.  Enter a filename and click on okay.  You do not need to enter the extension CPP, but for reasons that will be explained in 310, I would recommend getting in the habit of doing so.  Note also that there is an ‘Add to Project’ checkbox above, and that your project is already filled in just below it. 


Now you will notice that back in the IDE the window to the right (the source window) is no longer grayed-out and is available for typing in your code. 


Adding additional files to your workspace

If you are a first-time C++ programmer, this is all you will need to do to get coding.  However, as you begin creating and using entirely separate files in your projects, you will need to add additional files.  The good news is that the process is simply a repeat of the steps outlined just above.  However, be sure to give the appropriate extension to your file name (e.g. .CPP or .H  or .CXX, etc.). 


Close the workspace before beginning work on another program

Be warned about the following: Once you are done working with a given program and wish to begin another, do not simply add another file to your project.  Why?  Because when you tell the IDE to execute the program, the first thing it does is look for a function called ‘main’, and calls (runs) that function.  If you have two separate files both of which have a ‘main’ function, you will find that you only have access to the first file you typed.  The idea of a ‘main’ function will be made (somewhat) more clear following your first lecture in C++.  So, you must first close the project (workspace) in which you are currently working before embarking on another. 


To recap:  When you are done working with a program and are ready to begin another (or call it a day), you must close the workspace.  To do so, click on File, Close Workspace.

To close a workspace, click on File, Close Workspace





Type your code

Once you have managed to get a workspace up and open, you are ready to begin programming.  Type in some code.  If this is your first encounter with a C++ program, you may copy and paste the following code:

#include <iostream.h>


int main( )


cout << “Farewell to innocence” << endl;

return 0;



Compiling and Executing your Code

What you have just typed is called source code.  However, as stated earlier, the computer can’t interpret source code.  We need to let the IDE compile the source code into object code.  To do so, click on the build* icon   or alternatively, type ‘F7’.  Assuming there are no errors (a patently foolish assumption), you can then click on the execute icon or type CONTROL-F5.  This will bring up a DOS window where your program will run. 


Now to address the no-errors fallacy:  You may have noticed that when you compile your program, the output window (the long window just below the source window) jumps to life.  You will quickly enter into a love/hate relationship with this window.  Like an overzealous athletic trainer, it will examine every last letter of your code, refusing to rest until it has pointed out each and every error it can find.  However, it does try to figure out what the cause of those errors and bring them to your attention.  Initially, you will find the error messages very difficult to decipher, and may choose to simply go up to the indicated line and search from there.  Given time, you will become more adept at deciphering the jargon inherent in compiler-generated error messages. 

To Run a Program:

  1. Compile the program by clicking on the icon, or typing F7.
  2. If there are no errors, click on the execute icon or type Control-F5.







A few notes about compiler error messages:

  1. While the error message will give you a line number, that line is where the compiler discovered the error.  However, the error itself may have occurred some line(s) previously.  So don’t treat line numbers as gospel.  For example in the dialogue above, the error is found on line 7.  However the error itself is a missing semicolon that should be at the end of line 5.
  2. Just because the compiler says you have 3 errors does not make it so.  The errors you’ve made may mask a whole other slew of mistakes.  So when you fix the third mistake and triumphantly click on the compile button, do not succumb to grief if more errors pop up.  You may just as likely find that clearing up one mistake gets rid of them all.  (No promises though). 
  3. After you’ve spent a little time with the compiler, I strongly urge you to begin keeping a log of error messages and how you addressed them.  This is especially true for new or unusual messages. 


A slick little shortcut for working with the output screen:  Hitting ‘F4’ will take you to the first error message and instantly move the cursor to the culpable line of code.  Hitting ‘F4’ subsequent times will cycle you through each error message in turn.


Nobody’s Perfect

Just because you eventually get to the point where the compiler gives you the friendly ‘0 errors’ message does not mean that you have a perfect program.  There are certain kinds of errors the compiler is unable to catch.  Perhaps the most insidious category of errors are errors of logic.  This is somewhat analogous to a spell-checker not knowing the difference between “where” and “wear”.  If you mistakenly type “Wear or wear has my little dog gone”, the spell-checker will, of course, fail to flag the error. 


Similarly, you may find yourself typing a line of code such as:

sum  =  num1 * num2;

Even though you probably meant to add the two numbers rather than multiply them, the compiler will regard the above expression as a perfectly appropriate C++ statement. 

The compiler will not catch most errors of logic.




A Work of Art

Once you have finally appeased the compiler and are faced with the blessed “0 errors” message, you are ready to execute your program.  To do so, you can click on execute icon, or type CONTROL-F5.  This will bring up a DOS window and execute your program. 



Do I Really Need all this Stuff?

It won’t take long before you discover that in the compiling process, the compiler generates a whole bunch of other files, some of which are quite large.  In fact, if you are working from a floppy disk, you may find that you very quickly use up the entire floppy.  The good news is that unless you are planning to sell your program commercially, you won’t need any of these files.  The only files of interest to you (for storing somewhere) are the ones whose filenames end with the extension  .CPP,  .H, or .CXX.   We will refer to these as your source files.  So once you are done working with a program, you can shut down Visual C++, and get rid of all but the source files (those not ending in .CPP,  .H, or .CXX).   This includes the ‘debug’ directory. 


In fact, for those of you submitting your assignments on disk or via e-mail, the source-files are the only ones that you should turn in. 


A suggestion:  Because floppies are so slow and the IDE makes frequent disk accesses, I highly recommend that you do all your work on the hard-drive.  If you are working from a student lab or at another computer that is not yours personally, you can then just copy the aforementioned source files to a floppy for storage or later use. 


When you are done with your work, the only files you need to save are the source files.  (Those ending in CPP,  CXX, or H).







And In Conclusion….

If you have somehow struggled your way to this point in my jeremiad, and are feeling a bit overwhelmed, that’s okay.  It may seem like a great deal of material, but after going through these procedures a few times, you will begin doing them automatically.  Don’t get discouraged.  Remember:  Practice, man.  Practice.

* For now we will treat ‘build’ and ‘compile’ as building the same, although this is not entirely accurate.