Professional Documents
Culture Documents
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.
This window is for messages from the compiler/loader, especially error messages for typographical errors.
The icon in the upper left under the File choice is pressed to obtain an editor window.
Click this icon to obtain an editor window to type in your C++ program source.
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.
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.
Source code for C++ program (taken from "Problem Solving with C++"
Choose a directory to save the source file and other files that Visual C++ creates for you. After choosing the directory and typing in a program name, click on save.
Visual C++ requires the program be part of a 'project workspace' and is offering to create one for you. Click on Yes.
Improperly spelled keyword causes the error message displayed below. It should be 'char'.
Message window for Visual C++. The compiler is complaining here about a misspelled keyword. Use the editor to correct the typing mistake.
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.
For a successful build no errors should be found by the compiler or the linker. You can now execute the program.
10
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