[table of contents] [previous section] [next section]

5. Proper Indentation and Spacing

 

A consistent indentation style makes programs clear and easy to read. To indent a block of lines to the right in C++, highlight the block and press the Tab key.

 

6.Programming errors

 

1) Compilation errors

Errors that occur during compilation are called compilation errors or syntax errors. Compilation errors result from errors in code construction, such as mistyping a keyword, omitting some necessary punctuation, or using an opening brace without a corresponding  closing brace. These errors are easy to detect.

2) Runtime errors

Runtime errors are errors that cause a program to terminate abnormally. Runtime errors occur while an application is running if the environment detects an operation that is impossible to carry out. Typical runtime error is input errors.

3) Logic errors

Logic errors occur when a program does not perform the way it intended to.

 

7.Run c++ Program from the command lines

 

C++ programs can be run directly from operating systems. The following are the steps to follow:

1).From the “Start Menu”, Select “run”, open “cmd”, choose “ok”;

2).p:\> c: enter key; “cd program files”; “cd  Microsoft visual studio”; “cd VC98”; “cd Bin”;

3).under dir c:\program files\ Microsoft visual studio\ vc98\ bin>,  input “vcvars32.bat”, enter key;

4).Under c:\program files\ Microsoft visual studio\ vc98\ bin>, input “cl”, enter key;

5). Under c:\program files\ Microsoft visual studio\ vc98\ bin>, input “link”, enter key;

6).Input  \project folder name\Debug\project .exe file, enter key.

Then you can execute the project program.

 

Figure 13 the result of the example program

[table of contents] [previous section] [next section]