Tips on Using Microsoft Visual C++ Version 6.0

last updated 04/16/01 by zives

This page collects various tips about Microsoft Visual C++ system used in 142 and 143. If you learn other things that you think we should post here for the benefit of all, please send mail to cse142-webmaster@cs.washington.edu.

  1. What is a Microsoft Visual C++ Project/Work Space?
  2. How to Start a New Project/Workspace
  3. How to Open an Existing Project/Workspace
  4. Create a New Source File in Your Project
  5. Insert an Existing File into Your Project
  6. File name extensions
  7. How to Compile Your Program
  8. Keeping your homework on floppies, but the compiler's working files on the hard drive.
  9. How to Set a Breakpoint
  10. How to Run the Debugger
  11. Locating compile errors
  12. Finding mis-matched parentheses
  13. Recovering from a crash
  14. Visual C++ Version
  15. Does printf() seem to be broken?
  16. How much disk space is needed for MSVC 6.0?"
  17. Visual C++ online reference
  18. Using the Context-Sensitive Help
  19. Other Sources of Information on MSVC

What is a Microsoft Visual C++ Project/Workspace?

You should notice that the words project and workspace are easily confused. The following is freely plaigerized from Microsoft documentation:

A project workspace is the area defined that contains your projects and their configurations. A project is defined as a configuration and a group of files that produce an program or final binary file(s). A project workspace can contain multiple projects, even projects of different types (for instance, Microsoft Visual C++ and Microsoft Visual J++ projects).


How to Start a New Project/Workspace

Many people have asked how to create a new project/workspace from scratch.

Open an Existing Project/Workspace


Create a New Source File in Your Project

With your project/workspace open, do the following:

Insert an Existing File into Your Project

With your project/workspace open, do the following:

File name extensions

Usually,you'll only deal with the header files and C source files. The header files end in ".h" and the source files end in ".c" or ".cpp".


How to Compile Your Program


Keeping your homework on floppies, but the compiler's working files on the hard drive.

You might want to set up new projects you create so that they know how to keep your source files on your floppy diskette, but so that all of the intermediate files (and they are big and numerous!) are written to the c: drive. If you didn't do this, you would either have to copy all your source files back and forth a lot, or you'd have to suffer through some terribly slow compiling (that would likely fill up your diskette anyway). Here's what you should do, assuming you have your project and source files on a diskette.

After your project is created, pull down the "Project" menu, and choose "Settings." On the "General" tab of the dialog box that pops up, change the settings for both of the Output directories ("Intermediate files" and "Output files") from "Debug" to "c:\temp". Click OK, and then go to the file menu and choose "Save workspace." Now, everything that comes out of the compiler will be written to the C: drive, but all of the C++ code that you write will stay on your floppy. You do not need to cleanup anything on the C: drive when you're done, as those files are all binary.


How to Set a Breakpoint

  • You can set a breakpoint in your program so that your program stops execution when that line of your program is reached. To do this, put your cursor on the line in your program where you want execution to stop.
  • Click the icon from the toolbar (it is near the top right of the screen).
  • A large red dot should appear on the left side of the line.
  • To toggle the breakpoints off, again place the cursor on the line with the breakpoint. Click the icon once again.

    How to Run the Debugger

    The debugger allows you to see how your variables are changing as your program executes. This can help you find logic errors in your program. Also, you can find more information and tutorials about the MSVC debugger at the debugger page

    Locating compile errors

    Tired of counting lines in your .c file in response to compiler error messages such as "C:\test\main.c(6)"? You don't have to. Try double-clicking on the line " C:\test\main.c(6)". The compiler will jump to that line automatically.

    Here is another method: When you compile your project and get a list of errors in the output window, you can use the F4 key to step through those errors. Each time you press F4, the keyboard cursor will be moved to the line where the error occured and little blue arrow will be placed on the side of that line to show you where you are. Meanwhile, the current error will be highlighted (in blue) in the output window, so if you press F1 ( context-sensitive help) MSVC++ will bring up the help page for that error.


    Finding mis-matched parentheses

    If you press Ctrl-] when the cursor is in front of a parenthesis, that will move the cursor to the matching parenthesis in that pair. You can use this feature to make sure that you have the correct number of parenthesis in really complicated expressions. This also works for braces (both curly and non-curly).

    Recovering from a crash

    Visual C++ is not bug free and it will sometimes crash on the system. So save your work often. In case the Visual C++ compiler crashes, press "Ctrl+Alt+Delete" keys. In the task list, select Visual C++ and click the "End Task" button. If you continue having problems, it is best to restart your machine.

    Visual C++ version

    As of the time of this writing, the lab is running Visual C++ version 6.0. The previous version (5.0) is still in use by many students at home, but can be different in minor ways. See the
    MSVC 5.0 tips file for further information.

    Does printf() seem to be broken?

    If the project uses GP142.c, printf will behave a little bit differently. GP142.c hides a lot of windows programming details from you, so what works in a console application may not work in a windows applications. In particular:

    How much disk space is needed for MSVC 6.0?"

    The following is from the Microsoft page on Visual C++ v6:

    To run Microsoft Visual C++ version 6.0, you need:

    Professional Edition


    Visual C++ online reference

    Visual C++ has a huge amount of documentation on-line. It is organized as "books" on various topics, with each book containing many "articles". When you search the documentation, you may get quite a long list of articles. It can be hard to know which article will be helpful. Many of the articles discuss facilities of MSVC which are useful for professional software developers but not relevant to our course.

    Using the Context-Sensitive Help

    One of the most important features of MSVC++ to know is context-sensitive help. If you press the F1 key when you're editing a source file, MSVC will open up the page of help for the word that the keyboard cursor is currently in. For example, if you wanted to know more about the ingteger type, you use the arrow keys to move the cursor somewhere in the word "int" (or select part of that word) and press F1. If there is more than one page related to that subject, a list will be displayed, and clicking on any item in that list will take you to that page.

    Other Sources of Information on MSVC