A Microsoft Visual C++ project consists of many files, some of which may be quite large.  It is recommended that you store your working files on either a ZIP disk or in the Student Documents folder of the hard drive.  Of course if you are working on your own computer you should store all files on the hard drive. If you store your working files on a campus hard drive make sure that you copy the appropriate files (see below) to your own 3½-inch diskette or Zip disk before leaving the lab.  Remember to delete from the Student Documents folder any folders/files that you may have created.

 

 I suggest that you create a folder called CMPSC 101 (or CMPSC 201, or CSE 103) on your disk.  The remainder of this discussion below will use CSE 103 as the folder name.  Each project for CSE 103 will then be stored in a sub-folder of folder CSE 103.  Before proceeding create the folder CSE 103.

 

1. Click the Start button and select Programs.  Now select Microsoft Visual Studio.NET and finally Microsoft Visual Studio.NET.

 

2. Once in Visual Studio.NET wait for the Start Page to appear and then do the following:

a) Open a new project by clicking the New Project icon.  Select Visual C++ Projects on the left side of the New Project dialog box.

 

b) Select Win32 Project from the available Templates.  You may have to scroll down in the Templates window to see this selection.  Choose the path CSE 103 and then enter Lab Project for the Project name.   As you enter Lab Project for the Project Name the Location (path) will expand to CSE 103\Lab Project.  Pay careful attention to the path chosen.  Your C++ source code and the associated project files will be located in this path.

 

c) Click the Application Settings icon and then select Console application and Empty project.  Click the Finish button.

 

d) Click the Add New Item icon in the toolbar.  Choose C++ from the Templates window, give the file the name Lab One and click the Open button.

 

e) Enter the following program into the edit window.

 

#include <iostream>

 

using namespace std;

 

// Date: ?/??/2002

// Programmer: Pamela Programmer – CSE 103

// Discussion: My first C++ program

 

int main()

{

cout<<"Welcome to the world of C++."<<endl;

 

return 0;

}


f) Attempt to run your program by choosing Start Without Debugging from the Debug menu.  This process will automatically save the source code.  If your program contains one or more errors, a message window will appear explaining the error(s).  You must switch back to the edit window containing the source code, correct the error(s) and try again. 

 

g) If you are successful, a new window will be displayed containing the message Welcome to the world of C++.   The title bar of this window will say pathname\Lab One.exe.  Close this window by clicking pressing any key or clicking on the Close icon in the upper right-hand corner.

 

h) Print the source code by choosing Print from the File menu.

 

i) Close your project by choosing Close Solution from the File menu then close Visual Studio.NET by choosing Exit from the File menu.

 

j) Once again load Visual Studio.NET.  From the Start Page choose Open Project.  Use the Windows dialog box to navigate to the folder containing the project and open the project named Lab Project.vcproj.  Run the program as above.  Close the solution and exit Visual Studio.NET.

 

3. Follow the steps similar to those in 3 above to create, save, and execute a project called

Lab Project Two with  code in the file Lab Two.  The code is given below.

 

#include <iostream>

 

using namespace std;

 

// Date: ?/??/2002

// Programmer: Pamela Programmer – CSE 103

 

// Discussion: My second C++ program

 

int main()

 

{

int age;                                     // User's age in years

 

// Ask user for his/her age

cout<<"How old are you? ";

cin>>age;

 

// Report results

cout<<"You are "<<age<<" years old."<<endl;

cout<<"I hope you like C++."<<endl;

 

return 0;

}

 

Don’t forget to delete any folders/files created on the hard drive of the PSU lab computer.

Submit printed copies of both Lab One.cpp and Lab Two.cpp to the instructor.

 

Files created by Visual C++:  Assuming that you completed project Lab Project as outlined above, Visual C++ will create the following files and folders.

 

File or Folder

Description

Lab Project

Folder containing the project files and sub-folders

Lab One.cpp

File containing the C++ source code (your most important file)

Lab Project.vcproj

Project file

Lab Project.xxx

Other files related to the project

Debug

Sub-folder containing several files including Lab One.exe.  Some of these files are quite large and may not fit on a floppy disk.

 

Transferring files between computers:  Suppose that you created Lab Project as discussed above on a computer in the S1 lab.  Before logging off simply copy the file Lab One.cpp to your floppy disk and then remove the entire project folder from the hard drive.  To continue working on your assignment using another computer repeat the process of creating a new project but do not create a new C++ Source File.  Copy the file Lab One.cpp to the newly created project folder.  In Visual Studio.NET with the project opened C++ choose File/Open/File and select the file Lab One.cpp.  Right-click the mouse in the Project1.cpp window and select Move Lab One.cpp Into Project.  The Solution Explorer window should show the file Lab One.cpp as the only source file.  You are now set to run your program.