Chapter 3
Using the MS Visual C++ 5.0 Compiler
Objectives:
- Master the unique features of the MS Visual C++ compiler.
- Become familiar with the process of creating and running a program.
- Compile, link, and run programs.
- Use template files provided on the network drive in the computer lab and
on Web pages.
- Save the source file (.cpp) to your network folder.
Steps:
- Make sure that your computer and monitor are turned on.
- Log onto the computer.
- Start MS Visual C++.
Choose Start, Programs, Microsoft Visual C++, and Microsoft Visual C++
by dragging your mouse. Do not be alarmed if you see that the program MS
Developer Studio starts. Visual C++ is part of the Developer Studio suite
(similar to how MS Word is part of the MS Office suite).
- Choose File/New... from the menu. Click the "Files" tab. Select
"C++ Source File". Click OK.
- Type your program (the source code).
- Choose Build/Compile... from the menu.
- Click "Yes" when Visual C++ asks if you wish to create a new workspace.
- Navigate to your network folder.
- Type the file name for your computer program but make sure that
you use the extension ".cpp"
- Choose Build/Execute from the menu.
- Click "Yes" to the question of whether you want to build an .exe
file.
- You will either see your program's output in a black console window (if
you are lucky and have no syntax errors) or you will see one or more error
messages.
- If your program ran successfully, press any key to continue. Then, Save
As... to your network drive and be sure to use the .cpp file extension.
- If your program did not run successfully, you should double-click the first
error and try to figure out what you did wrong. A bullet will attempt to show
you where your error was located but you can never totally rely on that indicator.
If you do not see your syntax error(s) listed at the bottom of the screen
then choose Window/Tile Horizontally from the menu.
Practice Exercises:
- Follow the instructions above to create your first C++ source file named
"Exercise1" and execute that file. Type the code below when necessary.
Be sure to type the code exactly as it appears. C++ is very case-sensitive.
// Type your name here
// Exercise1
#include <iostream.h>
int main()
{
cout << "Exercise1" << endl;
return 0;
}
Compile and execute the program to make sure that it works before continuing
with the next exercise. Printout the source file by choosing File/Print...
from the menu.
- Create a new source file named "Exercise2". Then, use Copy and
Paste to transfer the code from any source file in my network folder.
I have placed many source files there that you will have to use to
finish homework assignments and lab exercises throughout the semester. Compile
and execute the program to make sure that it works before continuing with
the next exercise. If necessary, debug the program. Add your name to a comment
at the beginning of the program and print a hard copy of the source file.
- Create another new source file named, "Exercise3". Use Copy and
Paste to transfer the code from http://www.minich.com/education/wyo/cplusplus/cplusplusch3/FromWeb.htm/
to your new source file. Compile and execute the program to make sure that
it works. If necessary, debug the program. Add your name to a comment at the
beginning of the program and print the source file.
Honors/AP Comp Sci Using C++ Home Page
| Minich.com Web Design