Using Visual C++ in CSCI 1301/1302
Contents
Creating a new workspace and C++ program:
This creates a debug version of your program for testing and
verification.
Once your program is ready to submit,
you should create a release version,
as described in the next section.
- Launch Visual C++.
- Create project:
- Choose File --> New (Project tab should be on top).
- Select Win32 Console Application.
- Enter project name in Project Name dialog box.
- Make the location and path specification the drive letter of your flash drive. (This is where your file will be stored.)
- Click OK.
- You'll see Win32 Console Application Step 1/1. The default selection is "Empty Project".
- Click Finish.
- Click OK.
Now you have an empty project, and need a file:
- Create file:
- Choose File --> New (Files tab should be on top)
- Select C++ Source File
- Enter filename in file name dialog box.
- Click OK.
Now you have a workspace ready to go!
- Type in C++ source code.
- Click Save button to save your project..
- Choose Build --> Rebuild All. DO NOT CHOOSE COMPILE -- your computer will lock up.
- Check bottom window for syntax errors and warnings.
If you have any, fix them.
- Check bottom window for linker errors.
If you have any, fix them.
- Once your file links correctly, choose Build --> Execute filename.exe to run your program
- Print your output if desired.
- Return to Visual C++ window and close output window.
- Once project is finished, choose Build --> Clean to save disk space (optional)
- Choose File --> Close Workspace and click Yes
Creating a Release Version of Your Project
This creates a release version of your project, with only the files
needed to actually run your program.
All the debug files, which occupy a large amount of space, are omitted.
- Make sure you have built (compiled and linked) a project following the steps above.
- Choose Build --> Configurations
- Choose Release rather than Debug.
- Visual C++ will create a new subdirectory, "Release",
for your "projectX".
This subdirectory will contain only your executable version of the project,
without the debug files.
If you do not have access to a Zip drive outside of class,
you will need to save source code files (including header files) and
project files to a floppy disk.
The following methods will make it simpler for you to transfer all the
appropriate files,
and only the appropriate files, back and forth.
Saving Project Files to Floppy Disk
- Open Windows Explorer
- Select the floppy disk drive
- Create a new folder on the floppy disk and give it the name of your project
- Select the drive and folder where your project is currently stored
- Highlight and select all files ending in .cpp, .h, .dsp, .dsw,
.ncb, .opt.
Do not select any other files or folders!
- Drag those selected files to the folder you just created on your
floppy disk.
Transferring a Project from Floppy Disk to Hard/Flash Drive
This assumes you have used the above method to save your project to your floppy disk.
- Open Windows Explorer
- Click on the "+" beside your floppy disk to show all folders on the floppy disk
- If you are going to transfer your project to a hard disk,
click on the "+" beside that hard disk to show all folders on that disk.
- Select the folder containing your project on the floppy disk.
- Drag the entire folder to the "Temp" folder on the hard disk,
or to the Removable Disk if you are using a Flash drive.
- Close Windows Explorer
- Start Microsoft Visual C++
- Choose File --> Open Workspace
- Select the folder on the hard disk/Zip disk containing your project
- Open that workspace
Printing the Screen Output From Your Program
- Execute your program.
Once the output window is displayed,
- Press Alt-PrintScreen
- Choose Start --> Programs --> Accessories --> Paint
- Choose Edit --> Paste
- Choose File --> Print
- Return to your output window and press any key
Adding a File to your Project
If you want to add an existing file to your project,
there's no need to retype it or copy it.
Just add it to the project:
- Choose Project --> Add to Project --> Files
- Either type in the name of the file that you want to add, or
- Use the browser to locate the file that you want to add to the project
- Click OK
This document, copyright 2000, is a joint effort from Julia Benson,
Priscilla Dodds, and Gene Sheppard of the GPC Computer Science
Department.
Home