BGSU Logo
BGSU Home BGSU Academics BGSU Admissions The Arts BGSU Athletics Libraries Offices
Department of Computer Science
Computer Science Home Undergraduate Program Graduate Program Computer Science Faculty Academic Advising Mission and Vision
Small font Medium font Larger font Largest font
Left bracket Using Visual C++ Right bracket

The Microsoft Visual C++ compiler is available as part of Microsoft Visual Studio in all campus computer labs. If you'd like to own a personal copy of Visual Studio, see the instructions here.

These steps show you how to compile and execute a traditional C++ program using Visual C++. This will build a "console application" that allows you to use cin and cout and the other standard C++ features.

  1. Start Microsoft Visual Studio.
  2. Choose File | New | Project and you will see this screen:
    New Project VC++
  3. Click on Visual C++ in the left pane and click on CLR Empty Project in the right pane. Be sure that the top right corner says .NET Framework 3.5. Fill in the project name (Name:) and click the Browse button to select a directory for your project. Select a location on your personal hard disk or on a USB flash drive in a computer lab. Be sure that the box labeled "Create directory for solution" is unchecked. A new folder will be created in the specified location with the project's name. Then click OK. For this example, we assume drive E is the flash drive we are using.
  4. To create files to add to the project, such as your main C++ program, choose Project | Add New Item and you will see this dialog:
    Add File VC++
    Click on C++ File or on Header File and give the name of the file below. For your main program, you might choose the name main.cpp. Do not change the Location field. When you click Open, a window with this name will appear and you can begin to type your program.
  5. If you have files already available that you want to add to this project, such as supplied C++ implementation files or header files, first copy the files into the folder for this project. Then choose Project | Add Existing Item to add the files to the project.
  6. To edit an existing file, double-click the filename in the Solution Explorer window.
    Solution Explorer
  7. To compile your program, click Build | Build Solution.
  8. If there are error messages in the bottom window, double-click on each message to go to the location of the error in your file. Fix the errors and build your program again.
  9. Execute your program by pressing Ctrl-F5 or clicking Debug | Start Without Debugging. This will allow you to see any output generated by your program. To use the debugger, press F5 or click Debug | Start Debugging. If you use this approach, your output window might disappear before you have a chance to read it. To prevent this, click Debug | Start Without Debugging instead.

Use one of the following strategies to return to your project after closing Visual C++:

  1. double-click the solution file (which ends in extension .sln), or
  2. choose Open | Project/Solution from the File menu and choose the solution file (ends in .sln), or
  3. select the solution from Recent Projects at the bottom of the File menu.

Warning: Microsoft Visual C++ gives no warning or error for a statement such as the following:

if (a = 5) ... [which presumably should have been written "if (a = = 5) ..."]

To cause a warning to be generated for this situation, choose Project | Project Properties and click on C/C++ Command Line. You will see the window below:

C++ Command Line

Type /w14706 in the Additional options frame, click the Apply button, then click OK. You will now get the desired warning. Unfortunately, you will need to repeat this step for each C++ project.


webmaster@cs.bgsu.edu