CSC 215

Fall '98

Section 701

Using Visual C++ 5.0

Listed here are instructions for editing, compiling, building, and executing a simple C++ program using the Visual C++ 5.0 development environment in one of the DePaul computer labs. The instructions may also work in other places (eg, at home).

Brief explanation of the Visual C++ environment

When writing a program, there are a number of different kinds of files and directories created by you and by Visual. The two we'll work with for now are the project directory and the C++ source file. The project directory will contain most of the files created as a result of compiling, building, and running your program. The C++ source file contains the text of the program itself.

In the instructions that follow, you will see how to create a project directory that resides on one of the hard drives of the machine you're using and to create a source file so that it resides on your diskette. This means that when you have finished your session, your diskette will only have your source file. The other files, which will not fit on a diskette, will stay on the hard drive, where they will eventually be deleted. This is not a problem because, unlike the source file, these other files can easily be recreated. Let me emphasize that in a different way: The source file is not easy to recreate. Make frequent backups of the diskette containing your source files.

1. Start up Visual C++ 5.0

The Visual C++ 5.0 window will then shortly appear.

2. Create a project

Once you're in the Visual environment, your first step is to create a project.

3. Create a source file

The source file contains your program. Source files always end in the extension cpp.

You will now see a cursor inside a region of the main window of Visual C++. This is a text editor window.

4. Type in the program

Type your program in the text editor window. When you're finished, click on the File menu and select the Save option. This will write your source file onto your diskette.

5. Compile the program

Click on the Build menu. Select the Compile option. In a few moments, messages will appear in the small window at the bottom of the Visual C++ window. If the program compiled cleanly, you'll see a message indicating that there are 0 errors and 0 warnings.

6. Build the executable

Click on the Build menu. Select the Build option. In a few moments, messages will appear in the small window at the bottom of the Visual C++ window. If the program was built successfully, you'll see a message indicating that there are 0 errors and 0 warnings.

7. Run the program

Click on the Build menu. Select the Execute option. A console window will appear, in which you'll see your program's output.

8. Exiting Visual C++

To exit, click on the File menu and select Save All. Click again on the File menu and select Exit.