D. Common Programming Mistakes
The following list summarizes some of the more common programming mistakes made in C. They are not arranged in any particular order. Knowledge of these mistakes will hopefully help you avoid them in your own programs.
1. Misplacing a semicolon.
if ( j == 100 ); j = 0;
In the previous statements, the value of
j will always be set to 0 due to the misplaced semicolon after the closing parenthesis. Remember, this semicolon is syntactically valid (it represents the null statement), and, therefore, no error is produced by the compiler. This same type of mistake is frequently made in
2. Confusing the operator
= with the operator
This mistake is usually made inside an
while, or ...