The environment is industrial strength in that it can produce modern software of the power, reliability and usability required in industrial settings. Software can be produced for multiple environments, but the orientation is towards producing Windows applications with the typical Graphical User Interface (menus, icons, objects and use of the mouse). For CS1, however, all programs will be text oriented, with character input and output.
The programs will be produced in the window environment, but run in a DOS text window. The Visual C++ terminology for such a program is Console Program.
It is recommended that a directory (e. g. CS1 Programs) be created on your U: drive for your software projects in CS1. This will contribute to good file management. Each programming project will then be in a subdirectory of this directory.
Working with Visual C++ projects stored on diskette is very slow.
Projects should never, never, be stored on the C drive of lab
computers.
3. Create the file for your program (source file).
On the File Menu, click New and then click the Files
tab.
Specify the File name and select (by clicking) C++ Source
File (The name of the file may be the same as the project name or may
be different. Do not specify an extension. The default extension of .cpp
will be used for the source file).
Click the OK button. Double clicking the C++ Source
File icon will also work.
4. Enter your program (source code) into your file.
Except for the top menu and tools bars, your screen should now be divided
into three windows: an upper left window called the viewer window;
an upper right window called the editor window and a bottom window
called the results window. The viewer window is used for getting
different views of a project. For small projects it is not used much. The
editor window is used for entering your program. The results window shows
messages from the build operation.
Your program is entered into the editor window. Note that some editing
icons (cut, copy, etc.) and entries on the Edit menu are active when the
cursor in the edit window.
5. Build your executable program.
When you have completed the entering your program and checked it for
proper syntax, the building of your executable program can be initiated.
The Build operation is a two step process that compiles your program and
if there are no errors links the object code created by the compiler with
library files to create an executable program. The build can be started
in one of three ways: 1) click Build on the Build Menu, 2)
press the F7 key or 3) click on the Build icon (found on
the right of the lower toolbar at the top of the main window). If the program
is has correct syntax, the Build should be successful. Messages from the
build, including any compile errors, appear in the results window. If there
are no errors the following message should appear in the results window
when the operation is complete:
programName.exe - 0 error(s), 0 warning(s).
6. Finding and correcting syntax errors.
Syntax errors are typical for beginning programmers. If errors are
detected in the Build process, then the errors must be corrected and the
Build repeated until all errors are corrected. To find the line where the
compiler detected an error (Note: the actual error location is often on
a different line from where the compiler detected it.) you can double click
on the error message in the results window (Scroll if necessary.). A pointer
will appear on the left of the editor window that points to the line where
the error is detected. The cursor will also be located at that line of
code. Another method for locating errors is by pressing the F4 key.
Each time the F4 key is pressed the pointer moves to the next error location
and the corresponding error message is highlighted in the results window.
Repeat the Build after errors are corrected.
7. Testing the executable program.
After the Build is successful the program can be executed. The execution
is initiated by clicking Execute on the Build Menu or by
clicking the Execute icon on the right of the lower toolbar at the
top of the main window.
8. Getting a printout of a sample run. Getting a printout of a sample run requires copying the contents of the DOS window after a run onto the Clipboard, pasting it into Notepad and then printing. The steps are: 1) after the run is complete highlight all of the text in the DOS window with the mouse, 2) click on Edit Copy on the menu that is activated with the MSDOS icon in the upper left of the DOS window, 3) launch Notepad, 4) Click on Edit Paste in Notepad and 5) print from Notepad.
9. Leaving Visual C++.
When the project is complete, the project workspace should be closed
(very important for the next user). First, make sure all changes in your
code are saved by clicking the Save icon (for the icon to be active,
the cursor must be in the editor window). Then click on Close Workspace
on
the File Menu. Visual C++ may be exited by clicking Exit
on the File Menu or with the Close button in the upper right
corner of the main window.