1. Write c in a concise and clear way Program . This programming method is usually called kis ("Keep concise "). Do not write programs in odd ways.
2. Read all the C version manuals. I often refer to the C version manual to understand the rich features of this version and use these features correctly.
3. Computers and compilers are good instructors. If you are unsure about a feature of C, write a simple program, compile and run it, and see what happens.
4. Add comments describing the function purpose before each function.
5. The last character printed by the function executing the print operation should be the newline character (\ n ). This ensures that the cursor is positioned at the beginning of the new line. This can improve the reusability of software (software reusability is an important goal of the software development environment ).
6. The function body defined in curly braces should be written in indent format. This method highlights the functional structure of the program and makes the program easy to read.
7. Establish the indentation distance you like and use it in the future. Although you can use the tab key to set the indentation distance, the stop position of the tab key may be different in different environments. It is recommended that the indention distance of each layer be 1/4 inch Tab key hop length or three spaces.
8. Although <stdio. h> is dispensable in a program, it is recommended that <stdio. h> be included in every C program that uses the standard input/output library function. This helps the compiler locate errors in the program in the compilation phase rather than the execution phase. Errors During execution can be corrected at a higher cost.
9. Add a space after each comma to improve the readability of the program.
10. selecting meaningful variable names is helpful for the program's self-contained documentation (you can use less comments ).
11. It is only used as the identifier of the variable name. The first letter must be in lower case. The identifiers starting with uppercase letters and all uppercase letters have special meanings.
12. Variable names use multiple words to make the program more readable. Do not write words together (for example, totalcommissions), but separate words with underscores (for example, total_commissions). If you really want to write words, each word after the first word starts with an uppercase letter (for example, totalcommissions ).
13. Separate declared statements and executable statements in the function with empty rows. In this way, the end of the statement Declaration and the start of the executable statement can be highlighted.
14. Set a space on both sides of the binary operator. In this way, the binary operator is eye-catching and the program can be more readable.
15. If struct is written in indent format.
16. To improve program readability, add a blank line before and after each control structure.
17. Do not write multiple statements on the same line of the program.
18. Long statements can be folded into multiple rows. When a statement must be broken, select a meaningful breakpoint (for example, after a comma is used to separate the list) and write the broken line in indent format.
19. When writing expressions containing many operators, refer to the operator priority table. Make sure that the operators in the expressions are executed in the correct order. If you are unsure of the order in which operators are computed in a complex expression, use parentheses to forcibly calculate the order. Note that some operators in the C language (such as the value assignment operator =) are combined from right to left, rather than from left to right.