After you login, you can start Microsoft Visual Studio 2005 by doing the
following:
|
|
After you start Visual Studio, you'll see the following:
|
|
|
When writing software in Visual Studio there may be many source files and
various resource files. The notion of a Project in Visual Studio
is a way of encapsulating all of the files that are part of a piece of
software into a single entity. Thus, before you can ever start to program
in Visual Studio, you must create a Project.
To start a new project, do the following:
|
|
|
Although Visual Studio 2005 can assist you in creating large, complex
pieces of software, for the purpose of this class we are starting
small, and creating a simple Console Application (one where
all input & output is done via a simple terminal).
To create such an application, do the following:
You should know that to encapsulate all of the files associated with the project, Visual Studio will create a directory named whatever you named project (in step 4), and all files associated with the project will be placed within this directory. The directory will be created in the location specified in step 5. |
|
| For this step, simply click the Next button in the bottom right. |
|
|
Here we could setup a few different types of applications which are
quite common when developing software on Windows. Again, for the purpose of
this class, we want to create a simple console application with no
assistance from Visual Studio.
To do that, make sure you select the following:
|
|
| After you have completed the steps above, you'll return to Visual Studio 2005 and in the narrow window on the left (the Solution Explorer) you'll now see the project you have just created. Within that project will be a few default directories where we can now add source code to actually do something. |
|
Before writing source code, we must add a file to the project where we
can store the source code.
|
|
In the window that appears, you must do the following:
|
|
After you have completed the steps above, you'll return to the main Visual
Studio window and see the following:
|
|
|
Now that you have successfully created a Project and added files to
the project, it's time to start programming. The following is a simple
program that all students first learn to write, called the
"Hello World!" program.
Open the file that you just added to the Project (if you haven't closed it, it should still be open), and type in the code that you see in the image on the right. Note that the color of the code is added automatically by Visual Studio, and simply serves to help people read and understand the code more easily. |
|
After you have added the code as you see above, it's time to build
the program that your source code specifies (this is also called
compiling). To do this:
|
|
|
When building your source code into a program, Visual Studio will report
any errors or warnings in the Output window at the bottom of the
screen.
The last line of the output is a summary of all of the previous lines. If you have typed everything in correctly, you should see 1 succeeded, like in the image to the right. Otherwise, you have typed something in that is not "correct" C++, and Visual Studio will tell you where your error is at. |
|
|
After you have successfully built your solution as described in the previous
step, you have a program that you can run.
To run your program, do the following:
|
|
When you run your program, you will see the output of it in the terminal
window. For the "Hello World!" program, this is simply
Hello World!
Press any key to continue . . .
Note that the "Press any key to continue . . ." is added by Visual Studio,
so that you window does not automatically close after the program completes.
NOTE: If you have your projects stored in your My Documents folder (the default location), you'll see a warning similar to the one in the image to the right. While this warning message is annoying, it will not cause any serious problems and can be safely ignored. |
|
|
Now that you have successfully created a Project with source code that
runs a program, you might be asked to submit a digital copy of everything
for grading.
To do this, open up Windows Explorer and traverse to the directory where you saved the project. NOTE: This location is the exact same directory that you specified in step 5 of 3.1 Creating a Win32 Console Application above! In the image to the right, you'll see that the location shown at the top of Windows Explorer is exactly the same as what we specified in step 5 of 3.1 Creating a Win32 Console Application above. Once you have browsed to the correct location, you'll see a directory with the same name as the project you created. To create a ZIP archive of this entire project, do the following:
NOTE: You should close Visual Studio when creating this ZIP file. If you do not, the archiver may give an error saying that "some files are currently in use and cannot be archived". |
|
|
The arvhiver can produce two different types of archives... RAR format
archives and ZIP format archives. To create a ZIP version, make sure
that the ZIP option is selected in the Archive Format
window in the image to the right.
Once you have done that, click the OK button in the bottom right of the window, and the ZIP file will be created. |
|
|
After you have completed the above, you'll see a new file in the projects
directory. It will have the same name as the project directory, but it
will be a single file (a ZIP file), and not a directory.
See the image to the right. It is this ZIP file that you should submit whenever a digital copy of your code or project is required. |
|