Steps To Compile and Run A C++ Program: Compiler: Microsoft Visual C++ 6.0 Operating System: Windows
Steps To Compile and Run A C++ Program: Compiler: Microsoft Visual C++ 6.0 Operating System: Windows
Step 1. Start the Microsoft Visual C++ programming environment by clicking Start,
Microsoft Visual Studio, and Microsoft Visual C++.
The following is the startup screen for the Visual C++ environment.
1
This window is the
editor window when
This window is the the editor is active.
'class' window when
working on a project.
The icon in the upper left under the File choice is pressed to obtain an editor window.
When typing the C++ program source code no elements will be highlighted since the
editor treats the source code as a text file at this point.
If you wish the keyword highlighting to be activated you should explicitly save the file as
a .cpp file. See the explanation a few pages ahead.
2
Editor window. Type your
source code here.
After typing the C++ source code it should be saved as a .cpp file. The name should be
somewhat original. This does not include lab1.cpp, program1.cpp, or assignment.cpp.
The .cpp extension is necessary for the following steps to work correctly since the
compiler expects that extension for source files it should compile.
3
Use the File menu item.
4
Choose a directory to save
the source file and other
files that Visual C++
creates for you.
5
You now need to Build
the program to obtain an
executable.
6
Visual C++ requires the
program be part of a
'project workspace' and is
offering to create one for
you.
Click on Yes.
7
Improperly spelled keyword
causes the error message
displayed below. It should be
'char'.
8
Use the Build option on the menu to create
the executable. As you can see additional
menu choices are available now that the
program is part of a project.
9
For a successful build no errors should be found by
the compiler or the linker. You can now execute the
program.
10
Under the Build menu is an
Execute option.
11
The program will execute in its own window. The
numbers for the number of pods and peas in the pod
were entered and the program printed the information.
To return to the Visual C++ environment press a key
and the execution window will disappear.
12