C语言高质量编码规范
发布日期:2021-05-14 23:42:42 浏览次数:23 分类:精选文章

本文共 5930 字,大约阅读时间需要 19 分钟。

C���������������������������

������������������������������

������������������������������������������������������������������������������������������������������review������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

���������������������������������������������������������������������������������������������������������������������������������review���������������������������������������������review������������������������������������������������������������

������������������������������������

1. ���������������������

������������������������������������������������������������������������������������������������������������

  • ������������
  • ���������������������������������
  • ������������������������/������������������������
  • ������������������

���������������������������

/* Copyright (c) 2001, company. All rights reserved.
* ���������������filename.h
* ���������������������������������������
* ���������������������������������
* ���������������1.1
* ���������������(������������)������
* ���������������2021���4���5���
* ���������������1.0
* ������������������(������������)������
* ���������������2021���4���1���
*/

2. ������������������

���������������������������������������

  • ���������������������
  • ������������
  • ���������������������������
  • ���������������������

    • ������������������������������������������������ifndef/define/endif������������������������
    • ������������������������������<filename.h>������������������������������"filename.h"
    • ���������������������������������������������������������
    • ���������������������������������������������������������������������

    3. ������������������

    ���������������������������

  • ���������������������������������
  • ������������������������
  • ���������������������
  • 4. ������������������

    ������������������������

    • ���������������������������������������������������������������������
    • ������������������������������������������������������������������������������

    ���������������������������

    ��������� ������������ ������������
    source ��������� .c������
    include ��������� .h������
    lib ��������� ���������
    build ������������
    debug ������������

    5. ������������

    ������������������������������

    • ������������������������������������������������������
    • ���������������������������������
    • ���������������������������min-length & max-information���������
    • ���������������������������������������������
    • ���������������������������������������������������

    ���������������������

    • ���������������������������������������+���������
    • ���������������������������������������������������������������������������

    ������������������������������

    6. ���������������

    ������

    ������������������������������������������������������������������������������������������

    ���������������

    • ������������������������������������������
    • ������������������������������������������������
    • ������������������������������������������������������������������������������������

    ���������

    • ������������������������������
    • if���for���while������������������������������������������������������������
    if (������) {
    // ������������������������������������������������������
    }
    • ������������������������������������

    ������������������������������������������������������������������������������������������������

    ������������������������������

    • ���������������������������������������a + b
    • ������������������������������������sizeof(a)���a[0]
    • []���.���>���������������������������

    ������������

    • { ��� } ���������������������������������������������������������
    • ������������������������{������������������������

    ������������

    • ������������������������������70-80���������������
    • ���������������������������������������������������������������������������������
    • ������������������������������������������

    ������������������

    • underscore���ampersand������������������������int *x, y;
    • ���������������������������������

    7. ������

    ������������

    • ���������������// ...

    • ���������������/.../���/*...*/

    • ���������������������

      • ���������������������
      • ������������������
      • ������������������������������
      • ������������

    ���������������

    • ���������������������������������������������
    • ���������������������������������������������
    • ���������������������������������������������������������������
    • ������������������������������������������������������������
    • ������������������������������������

    ������������������������������������

    1. ������������������

    ������

    ������������������������������������������������������������������Debug���������������assert������������������������������������������������������������������

    • ������������������
    • ������������������
    • ������������������
    • ���������������������������
    • ���������������������������������

    ������������������������������

    #include 
    #include
    #include
    void out(FILE *spIn) {
    assert(spIn != NULL);
    }
    int main(void) {
    FILE *spIn;
    spIn = fopen("src/a.txt", "r");
    assert(spIn != NULL);
    spIn = NULL;
    out(spIn);
    return 0;
    }

    ���������������

    ������������������������������������������������������������������������������������������������

    • ������������������������������������������

    • ���������������������������������������������

    • ���������

      a = b = c = 0; // ������
    • ������������������������������������������������������������������������������

    if������

    • ���������������������������������TRUE���FALSE���0������������������������!("not")������������
    • ������==���!=���������������������0
    • ������>=���<=������������������������������

    const������

    ������const������������������������

    • ������������������
    • ������������������������������������������
    • ������������������const������������������������������������������

    ������������

    • malloc���������������������������������
    • ���������������������������������������
    • ������������������������������������

    ���������������

    void get_mem(char **p, int num) {
    p = (char **)malloc(sizeof(char) * num);
    }
    test:
    上一篇:makefile介绍
    下一篇:C字符串数组练习

    发表评论

    最新留言

    能坚持,总会有不一样的收获!
    [***.219.124.196]2025年04月24日 07时34分57秒