1. 分号问题:

 

a. 语句开头带“#”号的(#include、#define)末尾不加分号

     #define PI 3.14

 

b. 函数参数列表后面(小括号后面)、函数体后面(大括号后面)不加分号

    void fun(int param) { return 0; }

 

c. 对于判断语句、循环语句,条件部分(小括号后面)、主体部分末尾(大括号后面)不加分号

    if( x < 0 ) { x += 1; }

    while( y != 0 ) { y /= 2; }

 

d. 其他语句末尾都要加分号

 

e. 定义struct大括号末尾要加分号

    struct student { char name[10]; int age; };

 

posted on 2023-05-15 22:24  wkxnk  阅读(11)  评论(0编辑  收藏  举报