2. Create a project workspace.
On the File menu, click New and then click the Project.
Click on the Visual C++ projects folder.
Select Win32 Project.
Enter a name for your new project.
Change the location of this new project to your U: drive.
When the Applications Wizard pops up, select Applications Settings.
Click on the Console Applications radio button, and check the Empty
Project checkbox.
Click on the Finish button.
3. Create the file for your program (source file).
On the File pull-down menu, select Add New Item.
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.
If you want to use the C++ compiler do not specify
an extension, the default extension of .cpp will be used for the source file.
If you want to use the C compiler, use an extension
of .c for the source file.
Click the OK button. Double clicking the C++ Source File icon
might also work.
4. Enter your program (source code) into this new file.
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
by clicking Build projectName on the Build pull-down menu.
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.
If errors are detected in the Build process, then the errors must be
corrected and the Build repeated until the build completes successfully.
7. Testing the executable program.
After the Build is successful the program can be executed. The execution is
initiated by clicking "Start without debugging" (the ! )on the Debug
pull-down menu.
To maxmize compiler optimizations in Visual Studio .NET, go to Properties
--> Config Properties --> C/C++ and then:
- Optimization to /Ox (full)
- Code Generation, change Basic Runtime Checks to default
- General, Debug Information Format to disabled
To set a command-line parameter (which is read a runtime) in Visual Studio .NET, go to Properties --> Config Properties --> Debugging and then enter the parameter(s) in the command line field.
Importing an existing file into a Microsoft VisualStudio
.NET Project:
1. Launch Visual C++.
Click on the Start button. Move the mouse pointer
to Programs, then Microsoft VisualStudio .NET and then to
Microsoft
VisualStudio .NET again.. Click the left mouse button.
2. Create a project workspace.
On the File menu, click New and then click the Project.
Click on the Visual C++ projects folder.
Select Win32 Project.
Enter a name for your new project.
Change the location of this new project to your U: drive.
When the Applications Wizard pops up, select Applications Settings.
Click on the Console Applications radio button, and check the Empty
Project checkbox.
Click on the Finish button.
3. Copy your existing source code into the project directory you just created.
4. Add existing source code to the project.
On the File pull-down menu, select "Add Existing Item" and choose
the desired file.
Creating a Console Program in Microsoft VisualStudio
v6.0 or later:
1. Launch Visual C++.
Click on the Start button. Move the mouse
pointer to Programs, then Microsoft Visual Studio 6.0 and
then to
Microsoft Visual C++ 6.0. Click the left mouse
button.
2. Create a project workspace.
On the File menu, click New and then click the Projects
tab.
Specify the Project Name (e. g. Mercer2A).
Specify the Location (the directory for the creation of the
workspace, make sure it's on your U: drive).
Double click on the Win32 Console Application icon.
Select Empty Project.
Click on Finish, and then OK.
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.
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. 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.