Improvements to programming styles
-- Reading C ++ programming specifications
1. if for while do and other statements occupy one row, and {} must be added regardless of the number of statements executed {}.
2. initialize the variable while defining the variable.
3. Add spaces as appropriate.
4. The program delimiters {And} should have an exclusive line.
5. You cannot add too many comments, which are usually on the top or right.
6. Do not use = or! = To compare with any number, try to convert it to> = or <=
7. Improve the efficiency of nested loops,Try to place the long cycle on the inner layer and move the logical judgment to the external body of the circulating body.
8. Circular variables cannot be modified in the circular body to prevent loops from being out of control.
9. Do not forget the default branch when using the Switch.
10. Use goto With caution when appropriate.
11. If the function does not have any parameters, fill in with void.
12. If the parameter is a pointer and only used for input, add const to the front to prevent the pointer from being accidentally modified in the function body.
13. Strictly check the function entrance and exit to improve the function quality.
14. functions must be single and small in size.
15. After applying for memory with malloc, check whether the pointer is NULL immediately.
16. Remember to assign an initial value to the dynamic memory.
17. After free memory, set the pointer to NULL immediately.
18. Use explicit data type conversion whenever possible.
19. Do not write highly skillful code.