Lectures/Notes
|
Setting Up a Console Application in Visual Studio 2003Adapted from Stephen J. Chenney's TutorialModified by Yu-Chi Lai at 2005This tutorial will introduce you to VS03 and walk you through the creation of the classic Hello World program. There are five simple steps to this tutorial.
Step 1: Create a Console Project
|
|
We are now ready to add some actual code to our program. Enter (or
cut and paste) the following code into main.cpp which should already be open in the
main source window.
#include <iostream> using namespace std; int main(int argc, char** args) { cerr << "Hello World" << endl; return 0; }
I'm not going to explain this code as you are expected to have
a working understanding of C++ for this (and all future) tutorials.
Our project is very simple. We have but a single function currently
so it is easy to find the code we want. However, the projects for
559 can become rather large and finding that one function you want to
modify may not be so easy. Let's take a look at another VS03 window
that can help us. Choose View -> Class View to get the Class View window. This window is similar
to the Solution Explorer so you'll
probably want to place them together. This window shows our project
as a tree. However, the Class View
window breaks the project up by class and function rather than by file.
Right now we have only a single function main but later your projects will grow to multiply
classes each containing many functions. The Class View window will
prove invaluable when navigating such projects later in the course.
Unfortunately there are currently some issue with VS03 and AFS (the unified file system used by the department). VS03 creates some temporary files when compiling programs and AFS is currently preventing this from happening. So to remedy this situation we're going to have VS03 put the temporary files on the local drive. These files will be lost when you logout but they're only temporary files anyway so that's ok. Open the Class View window, right click on our project CS559 Tutorial and choose Properties. Select General from the left hand pane and set the Intermediate Directory to C:\Temp\Debug. The intermediate directory will have to be set in this manner for all projects you create in VS03. Click OK and we're all set to compile our project. |
To run our program from within the VS03 enviroment we simply choose Debug -> Start Without Debugging. You should see this console window appear. Congratulations! You've got your first successfull VS03 project. |