ENSC 104: DIGITAL COMPUTER PROGRAMMING
INTRODUCTION TO VISUAL C++
Creating a New Visual C++ Program
- Click on File->New.
- Make sure that the Projects Tab is in the front of this property page.
- Single click on Win32 Console Application.
- Change the location edit box to "C:\Students".
- Enter a project Name such as "demo" into the project name edit
box.
- Click OK.
- Select "A Hello World Application" from the Win32 Console
Application Dialog box and then click Finish.
- Click OK
- On the left is a window that displays ClassView and FileView. Make sure
that the ClassView tab is in front.
- Click the "+" on Demo
- Click the "+" on Globals
- Double click on "main( int argc, char *argv[] )"
- Now you may edit your program by simply typing in the program window.
- To save your program, click on File->Save All.
- To compile and run your program, click on Build->Execute.
- Visual C++ will ask you if you want to build an *.exe file. Click on Yes.
- If the program compiles without any errors, you should now see the output
on the screen.
- To remove the program output from the screen, press the ENTER key once.
- To print your source code, click on File->Print. Change the destination
printer to \\HARDY\hk104lj3 on Ne04: in
the drop down edit box. Then click OK.
- To close this project click on File->Close Workspace.
- Visual C++ may ask you if you want to close all document windows. Click Yes.
- To open this project back up after it has been closed, click File->Open
Workspace.
- Double click on the Folder that corresponds to your project name.
- Click on "demo.dsw" and then click OK to open your project.
Downloading a C++ Program from Dr. Walsh's Web Page
- Locate a hyperlink corresponding to a C++ program that you wish to
download.
- Right click on the link and choose "Save Target As..."
- Move to "C:\Students" in the
SaveAs Dialog box.
- Click Save.
- A Download Close Dialog box will appear. Just click Close.
- Within Visual C++, click File->Open.
- Select the program that you downloaded to the Students directory.
- Click Build->Build to compile and link your program.
- Visual C++ will tell you that there is no project workspace and asks you
if you want to build one. Click OK.
- To run your program, click on Build->Execute.
- You should now see your output.
- To reopen this project after it has been closed you will need to use
File->Open Workspace instead of File->Open.
Saving your project to a Floppy in the A: drive so that you may take it
home and then bring it back and work on it later.
- Save your program from within Visual C++.
- Exit Visual C++.
- Using the Explorer, traverse the your project directory under the Students
directory.
- Left click to highlight the files <filename>.cpp.
- Right click with <filename.cpp> still highlighted and select copy.
- Insert Floppy disk into the floppy drive.
- Using Explorer, traverse to the A: drive.
- Right click and select Paste.
- Traverse back to the project directory under the Students directory and
repeat the above steps to copy stdafx.h to the floppy.
- Using Explorer, delete everything in the Students directory.
- Log off the computer.
- Log back into the computer.
- Using Explorer, copy the two files on your floppy disk back to the
Students directory.
- Within Visual C++, click File->Open.
- Select the program that you copied from the A: drive to the Students directory.
- Click Build->Build.
- Visual C++ will tell you that there is no project workspace and asks you
if you want to build one. Click OK.
- Click on Build->Execute and your program will run.
- To reopen this project after it has been closed you will need to use
File->Open Workspace instead of File->Open.