Using the MS Visual C++ Compiler
- Start Visual C++.
- Go the the Tools/Options menu command. Scroll to the right
and click the "Workspace" tab. Change the "Recent workspace
contains" entry from a 4 to a 1. Place a checkmark in the "Reload
last workspace at startup" checkbox. Remove the checkmark in the "Reload
documents when opening workspace" checkbox. Click OK.
- Click the File/New... menu command. Click the "Workspace"
tab. Single-click "Blank Workspace". Type the name "MyWorkspace".
Type the location "H:\MyWorkspace". Click OK.
- Click the File/New... menu command. Click the "Projects"
tab. Single-click "Win32 Console Application". Type the project
name "MyProject". Click the "Add to workspace" option
button. Click OK. Click the "Finish" button wiht the "An empty
project" option selected. Click OK.
To create a new source file as if you are beginning a new programming assignment:
- Choose the menu command Project/Add to Project/New... menu
command.
- Click the "File" tab and single-click "C++
Source File". Type the name of your source file such as "Ch1Proj1.cpp".
Make sure the "Add to project" option button is clicked. Click the
build button (the three dots) and browse to the desired folder in which you
would like to place the new source file. (Your first program might be the
Ch1Proj1 hello world program in which case you should browse to your H:\C++\Ch01
folder. Click OK.
- Type your code. Use the Build/Compile... menu command to
compile the source code and check for errors. Debug the program if necessary
by double-clicking on the very first error listed in the error window. Do
not try to fix any error other than the first one listed. After fixing the
first error, recompile the program by using the Build/Compile menu commnand
again. Do not fix other errors since they may not really be errors at all.
- Execute your program, by clicking the Build/Execute menu
command. Click "Yes" to any dialog boxes that appear. You will then
see your program's output in a black DOS console window. Press any key such
as the space bar to close this window.
- To print your source file at any time, use the File/Print
menu command. Make sure that you do not have a word or phrase highlighted
when you print. You may need to use the Print/Setup/Effects and print at 200%
when printing in the Room 202 Wyo lab.
- Note that the act of compiling a source file automatically
saves the source file. You do not have to use the File/Save menu command to
save your file.
To close a source file:
- Close the current source file by clicking the "lower
x" in the upper-right corner. Or, use the File/Close menu command.
- Click the FileView tab at the bottom of the Workspace window
on the left. Click the plus (+) symbol next to the MyProject and Source files
folders if necessary. Single-click the current source file (such as Ch1Proj1.cpp).
Press the Delete key on your keyboard. This removes that source file from
the workspace & project but does not delete the file from your hard drive.
To open a previous source file:
- You cannot have two active source files in a project at
once. With an empty project that contains no source files (see steps above),
click the Project/Add to Project/Files... menu command. Browse to find the
source file that you wish to open. Once you have inserted the source file
into your project, you may need to double-click its entry in the Workspace
window on the left.
To exit Visual C++:
- Click the File/Exit menu command.