Visual Studio 2005 Express Edition
A Quick Tutorial
Jason Witherell (firstname.lastname@example.org)
Part I: Getting and Installing VC++:
- Go To:
sure you also download Service Pack 1 (SP1): Many projects you download
will not work unless you use the newest version of VC++
- If you
plan on writing Windows applications (i.e. not text-based), you will also
need to download the Platform SDK.
VC++ page has detailed descriptions of all the above steps.
Part II: Creating a VC++ project (Console application: i.e. text-based)
create an .exe file, you must first create a project. Follow these steps:
File => New => Project…
will see a Start Page with links to recent projects.
files to the project:
Project Types, select Win32
Templates, choose Win 32 Console Application
a Location of click the Browse… button. (for example, C:\temp\Labs)
a Project Name (for example, Lab03)
the Create Directory for Solution.
will create new solution files in C:\temp\Labs\Lab03.
you already have source files created elsewhere:
your source files to the solution folder.
to Project => Add Existing Item…
your files (Ctrl-click to select multiple files)
new files should be in the solution browser now.
you are making new source files from scratch.
to Project => Add New Item…
the appropriate type of file (Usually the Code category, and either .cpp or .files under Templates).
a name for the file.
new file will be added to the solution explorer and the new file will be
created in the solution directory.
compiles and links your source files into an .exe file.
to Build => Build Solution (or hit F7).
examples use this source code:
#pragma warning(disable: 4996) // Disable the scanf
Date stuff /////////////////
day, month, year;
Reading * r)
printf("%02d/%02d/%04d\t\t(%0.2f)\n", r->d.month, r->d.day, r->d.year, r->temp);
Reading * dlist , int dsize)
for (i=0; i<dsize;
Recursive stuff ////////////////////////
x, int y)
if (x < y)
* recursive_func(x-2, y+2);
Main program ////////////////////////////
struct Reading data;
= 50, i, v1, v2;
for (i=0; i<data_size;
data[i].d.day = i
data[i].d.month = i
/ 30 + 1;
data[i].d.year = 2007;
data[i].temp = (float)(50.0 + sin((float)i
/ 10.0f) );
printf("Integer Value #1: ");
printf("Integer Value #2: ");
result = recursive_func(v1, v2);
printf("recursive_func(%d, %d) returned
%f\n", v1, v2, result)
intentionally left off a trainling semi-colon
on the 4th-to-last line.
you have no errors, go to step 5.
you do have errors:
will get errors (and warning messages) in the Output Window (usually the
bottom of the screen).
you double-click on the error/warning line in the Output window, you
will be taken directly to the (vicinity of) the error in your source
your program is free of syntax
errors, you will get this output in the Output window:
your program is built successfully, you can run it.
are two modes:
with the Debugger: Hit F5 (see the next section)
without Debugging: Hit Ctrl-F5.
Part III: Using the Integrated Debugger
Debugger is a powerful tool to examine your program as it is running,
stopping at strategic points in the program to examine memory/variable
debugging involves the strategic placing of breakpoints.
set a breakpoint, click on a source code line and press F9
F9 again to remove the breakpoint.
will see a red dot in the margin next to a line with a set breakpoint.
mentioned, hit F5 to start Debug mode.
code will run until the first breakpoint is encountered:
use of each area of the debugger is discussed below:
code view and stepping:
Yellow arrow (),
shows the current execution point in the code.
line is about to be executed).
- To Step to the next line, hit F10
you want to “Jump-Into” the
current line, hit F11
this line contains a function call, this will show execution of that
this line contains multiple function calls, this will show the first.
you are in a function, and want to run the rest of the function, returning to the caller, press Shift-F11.
continue running the program to the end (or to the next breakpoint), hit F5 again.
call stack view
are several sub-panes in this window, discussed below:
Shows all variables active/used-by the current line of code.
Shows all variables within the current scope.
Shows any variables the user wishes to see.
Shows any active threads (useful for multi-threaded applications)
Shows and DLL’s being used by this program.
the Autos, Locals, and Watch panes:
entries indicate this variable has been changed since the last statement
(or since F5 was hit).
can manually change variable values.
structure or class can be “opened” by clicking the plus beside it (to
see the values of attributes/fields).
enter a watch variable, type its name on a blank line.
the stack of function activation records.
yellow arrow shows the current context.
double-clicking on a line, you can change the context (it doesn’t affect
the current code location).
an area of code has no symbols loaded, you will see the assembly language
useful for class files. Allows you
to select the class in the left drop-down and the method on the right. You are then taken directly to that
Memory and Register Debug views are useful to see the contents of the
CPU/Memory at a given time.