Microsoft
Visual Studio 2008 Console Program Projects Dr. Woelfl
Writing and testing a program in Visual C++ requires
working with a project.
After starting Visual C++, on top-left select
·
File and New Project
Upper left of new window under project types, expand
Visual C++ project types and select
·
Win32 for a console application
·
in lower section of new window, type in a name
for the project (a different directory can be entered for Location).
·
Double click on Win 32 Console
Application
·
Click on Application Settings and check Empty Project
·
Select Finish.
To add file for source code, highlight
·
Right click in the left pane showing the project folder and choose add
then New Item
·
Enter a name for the source code file and double click on C++ File
(C++)
·
Source code can
now be typed in the c++ file
After the program has been typed in, select
·
Build and Compile
Any error massages will be displayed in the bottom
frame of the window; highlight an error message and double click to bring the
curser to the line of code causing the error (carefully read the message for
guidance on fixing the error, although sometimes error messages can be
cryptic). Again, select Build and
Compile or click on <F5> to compile link and run the program. In the future just
·
press <F5> to link, create an executable
file, and run the program.
Adding an input text data
file
·
at top-left select File, New, and
File and choose text file.
·
select File and Save As to save file;
·
to avoid using a path name, Browse to find project
file and save inside the project file – and inside file with
the project name.
Viewing an output file
If your program opens an output file for writing data,
this file can be viewed after running the program by selecting
·
File and Open
·
then under Files of type, choose All Files
(*.*) and select the output file.
·
use the tabs
along the top to choose a source, text, or output file to view or edit.
Saving and Reopening a Project Folder
To save a backup of the project, delete the Debug
folder since this contains several large files and can easily be
recreated, then copy the project folder. In the future, if you open the copied project
from the disk since there may not be sufficient room to rebuild the project on
the disk. First copy
the project folder to the C drive and open it from
there.
·
Note the listing
of projects you have been working on.
·
If the Debug
folder was deleted, it can be recreated by pressing <f5> key which
rebuilds the files in the Debug folder.
·
You can also open
a project by double clicking on the Project file (*.vcproj). Avoid opening the source code file
unless you will not be working on the project!
Saving and Using a Source Code File
Alternatively, just save the source
code file (*.cpp).
If only the source code file is available, a new
project must be created. Start by placing
your source code on the clip board (use Notepad); create a new project
and simply paste your code into the newly created source code file.
Make sure
you backup your projects as you are working on them in the event of a crash!