Introduction to Using Visual C++
Step 1: Create a Project:
- Use FILE | NEW
- Select PROJECTS
- Select WIN 32 CONSOLE APPLICATION
- Enter project NAME and LOCATION
- Click OK
Step 2: Add Existing Files to the Project
- Use PROJECT | ADD TO PROJECT |FILES
- Select *.* for ALL FILE types
- Select desired files (you can include source files and and
object files) and click OK
Step 2a: Add New Files to the Project
- Use PROJECT | ADD TO PROJECT | NEW
- Select the type of file to create (source file for a *.cpp
file)
- Give the file a Name and verify the path (it should be
correct)
- Click OK
- Write/edit the file in the file window
.
Step 3: Compiling a Source File
- In the Workspace display window (left pane), click on the
File View tab
- Double-click on the name of the source file you want to work
with (this will open the file in the right window)
- If the file is ready to compile, use BUILD | COMPILE or the
COMPILE icon on the toolbar to compile the file.
- Compilation results and errors will be listed in the window
at the bottom of the screen.
- To view the code associated with an error, you can either
(1) use F4 to go to the NEXT ERROR, or (2) double-click on the error message in the
compilation window.
Step 4: Building the Executable File
- Once the source files are compiled, use BUILD | *.EXE or the
BUILD icon on the toolbar to link the object files created from the source files with any
other files or libraries needed.
- NOTE: BUILD | *.EXE will also compile any changed source
files and perform linking in one step, as long as there are no errors in the source code.
- You can also use BUILD | REBUILD ALL to recompile and relink
all files
Step 5: Running the Program
- Use BUILD | EXECUTE, CTRL-F5,
or EXECUTE icon (Exclamation mark) to run the program without stopping,
and leave the final window open for viewing the program results.
- Use BUILD | START DEBUG | RUN, F5,
or RUN icon (program with down arrow beside it) to run program to a
preset breakpoint, then stop for debugging.
- Use BUILD | START DEBUG | STEP INTO or F8
to start the program by stepping into the first step.
- Use BUILD | START DEBUG | RUN TO CURSOR or F7
to start the program and run it to the current cursor location.
- When using the debug mode, you can use various options to
step through the program, jump over subroutines, etc.
Configuration Options in Visual C++
- Use TOOLS | OPTIONS to set general options (such as tab
sizes) associated with using the VC++ environment.
- Use BUILD | SET ACTIVE CONFIGURATION to set either DEBUG or
RELEASE as the current configuration for building executable files. Note: use DEBUG as the
configuration for building executable files for assignments. A DEBUG version of a program
includes additional information/instructions that allows you to use the debugging features
when testing your program.
Debug Features
- Variables window --- auto, local
- Watch windows
--- useful for tracking status of global
variables
- Breakpoints ---
allow you to run to a certain point in
the code where you want to start debugging.
- Step Into
--- allows you to trace program execution
line-by-line into functions you want to debug.
- Step Over
--- allows you to trace program execution
WITHOUT going into functions you don't want to debug.