Flylib.com

Books Software

 
 
 

11. Complete IO in C

Chapter 3 - Writing, Compiling, and Debugging Simple Programs

Visual C++ 6: The Complete Reference
Chris H. Pappas and William H. Murray, III
  Copyright 1998 The McGraw-Hill Companies

Editing Source Code
One of the main reasons for the success of Microsoft Windows is the graphical user interface (GUI). Windows 98/95 has introduced a modified GUI, but one that is intuitive to the experienced Windows user. A consistent user GUI means that when a particular feature appears in two different applications—for example, a Windows word processor and the Visual C++ IDE editor—that feature usually has the same menu and keyboard commands, in the same locations, in both applications.
This means that even if you have never used the Visual C++ IDE editor, you should find that correcting mistakes or moving to the end of a line, the beginning of a line, or the bottom of the edit window is just as easy and familiar as it is in your favorite Windows word processor.
Here are some helpful tips for working with the Visual C++ IDE editor. To move quickly through a line, hold down the CTRL key while pressing the left or right cursor key. This causes the edit cursor to move to the right or the left (depending on the cursor key pressed) one whole word at a time. (A word is defined as anything delimited by a blank space or punctuation.)
To delete an entire word instead of a single character, place the cursor on the space before or after the word to be deleted and press either ctrl-delete (to delete the word to the right) or ctrl- backspace (to delete the word to the left).
To allow for the maximum amount of editing workspace, the horizontal and vertical scroll bars can be turned off ( see Tools Options ). If you chose this option, the mouse cannot be used to scroll the window, either horizontally or vertically. For this reason, you need to know two key combinations: ctrl-page up, which moves you to the top of a program; and ctrl-end, which moves you to the bottom of a program. How are you doing with that highlighter?
Perhaps you are wondering why we have made no mention of the horizontal movement keyboard equivalents. There is a reason: Most professionally written code fits within the standard monitors 80-column width. This makes for easy reading and code debugging—since each line of code is completely visible, there can be no hidden bugs in column 95.

Books24x7.com, Inc 2000 –  

Chapter 3 - Writing, Compiling, and Debugging Simple Programs

Visual C++ 6: The Complete Reference
Chris H. Pappas and William H. Murray, III
  Copyright 1998 The McGraw-Hill Companies

Saving Files
There is usually a major conflict between you and the compiler. You think that you write flawless code, while the compiler believes otherwise . If that insult is not bad enough, theres the linkers impression of your algorithmic genius. However, the final blow to your ego comes from the microprocessor itself, which, after being passed an executable file filtered by both the compiler and the linker, chokes on your digital instructions.
Although disagreements between you and the compiler or the linker are not catastrophic, disagreements between you and the microprocessor are. So, heres the moral to this story: Save your file before you compile, before you link, and definitely before you try to run a program. Many a sad story has been told of a programmer who runs an unsaved file, crashes the application or the system, and then has to reenter the entire program.
If you have not already done so, save the example program you are working with. You can do so by either clicking on the third button from the left on the toolbar (the picture on this button looks like a 3 1/2-inch floppy disk), using the File Save command, or pressing ctrl-s.
The first time you save a file, the IDE will present you with a Save dialog box. Save this file under the name ERROR.C.
Figure 3-3 shows the edit window as it looks just before the file is saved. After the file is saved, the title in the title bar will show the saved files name.
Figure 3-3: The Visual C++ edit window previous to saving a file for the first time

Books24x7.com, Inc 2000 –