![](http://www.depaul.edu/~jrogers/Images/dputree.gif) |
CSC 215 |
|
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
- At the bottom of the Windows '95 screen is a bar with an icon
labeled Start. Click this icon.
- A menu will appear on which you'll find the option
Programs. Click this option.
- Another menu will appear on which you'll find the option
Microsoft Visual C++ 5.0. Click this option.
- Another menu will appear on which you'll (again) find the option
Microsoft Visual C++ 5.0. Click this option.
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.
- Click on the File menu on the menubar at the top of the
window.
- Click on the New... option on the menu that appears.
- A window will appear with four tabs at the top. Click on the tab
labeled Projects.
- Below the tab, a list of project types will appear. Click on the
entry that says Win32 Console Application.
- Find the Project name box in the upper right corner of the
window and click in it. Type in the name of your project. This can
be any name. I suggest using your shrike username.
- Below the project name box is a box labeled Location. Make
certain that this box has a pathname beginning either with D: or
E:. This will cause the (rather large) project directory to be put
onto one of the machine's hard drives.
- Click on the OK button at the lower right of the window.
3. Create a source file
The source file contains your program. Source files always end in the
extension cpp.
- Again, click on the File menu on the menubar at the top of
the window.
- Click on the New... option on the menu that appears.
- A window will appear with four tabs at the top. Click on the tab
labeled Files.
- Below the tab, a list of file types will appear. Click on the
entry that says C++ Source File.
- Find the File name box on the right side of the window and
click in it. Type in the name of your file. This should be a name with up
to eight letters followed by a dot and the extension cpp. For
example, for the first program use the name goodbye.cpp.
- Below the file name box is a box labeled Location. Click
in here and type a:\. This will place your source file onto
your diskette.
- Click on the OK button at the lower right of the window.
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.