The best way to write error-free code is to put prevention errors first.
1, the null statement after the statement question?
A while statement is a circular statement that sometimes requires null statements and sometimes no empty statements. In order to avoid misuse of statements
We specify that when a while uses an empty statement, the following methods are used:
while (*pchto++ = *pchfrom)
NULL;
The advantage of using NULL is that the compiler does not generate the code for the task for the null statement, because NULL is just a constant.
2. Use lint to find out the errors that the compiler missed
3, if there is unit testing, the unit test
4, both maintenance of the delivery version of the program, but also maintain the debug version of the program.
5, to use the assertion of the function parameters to confirm
6, to remove the undefined feature from the program or use assertions in the program to check out the illegal use of undefined attributes.
7, do not waste other people's time--detailed description of unclear assertions
8, eliminate all implicit assumptions, or check their correctness with assertions
9. Use assertions to check for situations that cannot happen
10, in the error-proofing design, do not hide the wrong
11, to use different algorithms to confirm the results of the program
12, do not wait for errors to occur, to use the initial check program