|
|
This section is intended to be a tutorial for PIC10A students on how to set up your first homework assignment.
READ THIS: There are a lot of steps here that you must go through in order to simply get started. Try to work through each step; Visual Studio is very picky, and if you miss just one thing, you will probably run into errors. If you follow the steps faithfully, you will not have any problems getting set up. If you have any questions, don't hesitate to ask a Lab Assistant.
Creating a solution
A solution, formerly known as a workspace, is Visual Studio's way of tying together all your projects. You will probably only need one solution throughout the quarter, so you can call it something like PIC10A.
- Open Microsoft Visual Studio: click Start->Programs->Microsoft Visual Studio .NET 2003->Microsoft Visual Studio .NET 2003
- Create a new solution: click File->New->Blank Solution...
- First, make sure the "Location" box is somewhere on your Z: drive. Click on the Browse button to the right of the box and locate the Z: drive. (A common value to put in here is
Z:\)- Next, give your solution a name (for example,
PIC10A)- Click OK. Your solution will appear on the right-hand side of the screen. A folder will be created on your Z: drive with the same name as your solution. This is where you will find all your files.
Creating a project
A project is Visual Studio's way of tying together all the files associated with a certain homework assignment. You should create a new project for each homework assignment you do and add it to your workspace.
- Create a new project: click File->New->Project
- Click on "Visual C++ Projects" in the Project Types box on the left.
- In the Templates box on the right, select "Win32 Console Project" by clicking once on it.
- Give your project a name (for example
project1). This name cannot have spaces or special characters. By default, this name will be the name of your executable file as well.- Click "Add to Solution", in the lower left hand corner, to make sure the project is created within your solution.
- Click OK.
- Do NOT click Finish. Instead, click once on the "Application Settings" link on the left.
- Choose "Empty project" for Additional options.
- Click Finish. By default, a folder will be created with the same name as your project. Your source code files will be in this folder once you have added them.
Adding files to your project
The files are the most important part of your project. These are the windows in which you type your code.You are now ready to get started on typing up your code!
- Create a new file: Right-click on the name of your project in the Solution Explorer box.
- Click on Add->Add New Item
- Select "C++ File" by clicking once on it. (In the future you may need to create Header files)
- Give your file a name in the "Name" box. The file name should end in
.cpp. The name of your cpp file must exactly match the name given by the professor on the assignment description!- Click Open.
Running your program
Once you have typed up all your code, you will need to run your program to test its behavior.Please see the section on Building Executables for more information.
- Click on Debug (6th from the left at the top of the screen)
- Find the red exclamation mark labeled "Start Without Debugging", and click it. DO NOT click the blue arrow labeled "Debug"!
- You will probably see the following message:
"These project configuration(s) are out of date:
...
Would you like to build them?"
Click "Yes". This will basically save your files and build your executable (.exe) program for running. Every time you modify/update your files and want to run your program again, you will have to respond "Yes" to this prompt to get your program to run.- Your program will now run.
- In your project folder, i.e., the folder in which your .cpp files reside, a new folder called "Debug" will be created. Your .exe file will be here. This is your actual program.
Submitting your program - the final step
To submit your homework for grading, you will need to copy all the required files into the "Submit" folder on your Z: drive. Your homework assignment should list which files you will need to turn in.
- To find your files, first open up My Computer on your desktop. If you do not know how to reach your desktop, simply right click on the "Start" button in the bottom left corner of your screen, and select "Explore".
- Find your Z: drive. It should be at the same level you normally find your C: drive. Double click on your Z: drive.
- If you have done everything exactly as described above, you should see a folder named "PIC10A". Double click this folder.
- In the PIC10A folder, you should see a folder with the same name as the project you just created. Double click this folder.
- Your .cpp files should be in this folder. For each file you need to turn in, right click the file and select copy.
- Your Submit folder will be at the top level of the Z: drive. Paste the file into this folder.
Believe it or not, all of these convoluted steps are actually there to make your life easier. Visual Studio tries to provide you, the programmer, with the maximum flexibility in creating your software. One way it does this is by providing a multitude of options for you. The price is a steeper learning curve and increased setup time.
Last updated by Nick Keller.
|
|
||
|
Feedback PIC Lab home |
UCLA Department of Mathematics Program in Computing - PIC Lab 2817 Boelter Hall / 310-825-7267 |
|
|
This page last updated:
June 28, 2001
|
||