Stability of C programming principles

Source: Internet
Author: User

See http://blog.csdn.net/xpzhang/archive/2007/01/22/1489860.aspx for the latest version

1. Do not forget the initialization process for variables, especially pointers and arrays !!!

2. Do not treat unsigned char (INT) variables or arrays as char (INT !!!

3. Do not ignore if, else, default, and other special circumstances in switch !!!

4. Avoid non-bool results in the IF condition judgment while !!!

5. Try to avoid using malloc/free. Once used, try to implement matching malloc and free in the same function !!!

6. Do not ignore the processing of malloc failures. Do not forget to set the pointer to null after being free !!!

7. The function body should not be too large to avoid repeated writes.CodeWhich can be encapsulated as a function with independent functions !!!

8. Avoid using global variables in a functional function (a function that is written for a specific function and can be called repeatedly !!!

9. Do not ignoreProgramAny warning that appears during compilation !!!

10. Let your program code be read clearly and properly. Variable and function naming rules !!!

11. Put architecture design first, make it more detailed, give more time, and continue to modify and improve as needed !!!

 

Not perfect yet. Leave a message.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.