C++ Programming Tutorial
Programming in C++ in the Lab
(Or How To Use Visual Studio)
In this lab, we'll be using Visual Studio, a Microsoft product, to
program in C++ for the tutorial. (We'll use a different environment
for Project Illuminate.)
Visual Studio has many tools for advanced programmers, so we have
created streamlined instructions to help you only access the features
you need. Those instructions are below. Unfortunately, you'll need
to follow them for every program you write in the tutorial, as
you'll need to create a new project for each task in the tutorial.
It is very important that you carefully follow each step.
- First, click on the Start menu and then click on All
Programs. Under All Programs, find Microsoft Visual
Studio 2010 and click on it. If a dialog box appears,
choose General Development Settings.
- From the menu in the left-hand column, choose New
Project and then choose Win32 Console Application (this
just means you are creating an application that runs in Windows and
prints to the screen). Name your project, browse to a location on
your USB stick, and click OK.
- Click Next.
- Next, check Empty Project (this will
uncheck Precompiled header), and then click Finish.
You now have a new project!
- Now you'll need to add a source file---this is the file where you
type your code. Right click on Source Files,
select Add and then New Item.
- From the resulting menu, choose C++ File (.cpp), enter a
name (this can be the same name as your project) and the .cpp file extension, and
- Add your code.
- Once you have finished typing your code, you must compile
it, or convert it from the (basically) English version you typed in
into the language understood by the machine (which is all 0s and 1s).
To compile, press F7. This is also known as building
the project. Check the output at the bottom of the window to see if
the build was a success. If it was not, see if you can understand and
then fix the given errors. If you can't, please ask us! Compiler
errors can by cryptic.
- Once your program is compiled, you are ready to run (or execute)
it. Do this by simultaneously pressing the Ctrl key
and F5 (this is often typed as Ctrl-F5). A console
window should appear with your output.
- Many things can go wrong when you are programming, so please ask
for help before you get frustrated!