Thought for the day

வெள்ளி, 18 டிசம்பர், 2009

Programing in C++ using Visual C++

There are various tasks you should be able to do (after launching Visual C++):
1. enter new C++ program files
2. retrieve already written (e.g., from the text book) C++ program files
3. build (compile) C++ programs
4. correct syntax errors
5. once syntax errors have been corrected, link and execute programs
6. retrieve and continue working on programs you have entered in a previous session
7. print the output from programs and the programs themselves
8. clean out your hard drive files, and move files from the hard drive to floppy disks
9. copy programs from your floppy disk to the hard drive

1. To begin a completely new C++ program
 click File, then click New (shortcut = Ctrl + N)
 in the New window
 click the Files tab
 select C++ Source File
 in the File name window, enter a name of your choosing (like Payroll Main Program)
 in the Location window, make sure that the folder H:\cpp (in one of our labs) or C:\cpp (on your own PC) is selected
 Click OK
 type in the program (this is where most of your work will go on!!!)

2. To retrieve an existing C++ program (like one from the text book)
 click File, then click Open (shortcut = Ctrl + O—NOTE: if the program is on a floppy, you must first copy it to the hard drive—follow the steps in #9 below)
 select the appropriate folder
 if it’s one of your programs, the folder should be H:\cpp or C:\cpp
 if it’s a textbook program, the folder will be a subfolder of the appropriate text's files
 click the file you want, then click Open

3. To compile a program:
 click Build, then click Compile (shortcut = Ctrl + F7—or click on the icon)
 if you are working with a program the first time, you will get the following screen:

click Yes

4. If there are syntax errors
 Double click on each error in the output box (bottom of screen). Examine the statement which is pointed to in the source code area (or the one before it). Hopefully, you will spot the error(s) in the statement and correct it (them).
 recompile: click Build, then click Compile again (shortcut = Ctrl + F7—or click on the icon)

5. When (finally!) there are no syntax errors, build (link) the program and execute it:
 click Build, then click Build again (shortcut = F7—or click on the icon)
 to execute the program, click Build, then click Execute (shortcut = Ctrl + F5—or click on the icon)

6. To retrieve and continue working on a program you have already started
 follow the steps in #2 above

7. To print the output from your program and your C++ program itself (assuming the standard [cout] output)
 left-click on the icon in the top left corner of the screen (the icon shows C:\ in Windows XP)
 scroll down to Edit and over to Mark and left-click
 highlight the output you wish to print
 hit the Enter key to copy the selected portion onto the clipboard
 hit any key to terminate the program
 paste the clipboard contents (Ctrl + V) into the output comment area of your program
 print the program and its output with File, Print (or Ctrl + P)

8. To clean out the hard drive files, and move program files to a floppy disk
 clean out the Debug directory, by clicking on Build, then on Clean—make sure to do this step
 exit Visual C++
 launch Windows Explorer
 click on the cpp directory icon in the left-hand window, and then click on the program in the right-hand window
 cut the program with Ctrl + X
 paste the program by clicking on the 3 ½ Floppy (A:) icon at the top of the left-hand window, then using the shortcut Ctrl + V

9. To copy files from your floppy disk to the hard drive
 launch Windows Explorer
 click on the 3 ½ Floppy (A:) icon at the top of the left-hand window
 drag the program you are working on from the right-hand pane onto the H:\cpp or C:\cpp folder in the left-hand window