We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
有问题的写法
int main() { int sum(int x,int y); sum(1, 2); return 0; } int sum(int x,int y) { return x + y; }
正确写法
int sum(int x,int y); int main() { sum(1, 2); return 0; } int sum(int x,int y) { return x + y; }
struct
union
// 重复定义 struct Point { int x,y; }; int main() { struct Point { int st,en; }; return 0; }
//镶嵌定义 struct Point { struct node { int a,b; }; }; int main() { return 0; }
enum
enum day{ Monday = 0, Tuesday = 1, }; int main() { enum day { Wednesday = 2, Thursday = 3, }; return 0; }
建议的写法
enum day{ Monday = 0, Tuesday = 1, }; int main() { enum { Wednesday = 2, Thursday = 3, }; return 0; }
typedef
typedef double INT; int main() { typedef int INT; return 0; }
typedef double INT; int main() { int INT = 0; return 0; }
#define
目前语法解析错误的代码
#define INT int int main() { INT x = 0; return 0; }
int main(); int main() { return 0; }
int sum(x,y) int x,y; { return 0; }
label
typdef
最后建议结构体不要定义在函数内部。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
C 语言在开发测试的时候应该避免的写法
1 函数内部声明
有问题的写法
正确写法
2
struct
、union
镶嵌定义 和 重复定义有问题的写法
3
enum
的名称的重复定义有问题的写法
建议的写法
4
typedef
定义的类型名不要在用作其他变量有问题的写法
5 千万千万不要用
#define
!目前语法解析错误的代码
6 main函数不要声明
7 一种古老的函数定义 还没有处理
已经处理的情况
typedef
的情况外)struct
,union
内部成员变量等价label
(标签)的等价enum
定义的变量等价typdef
自定义类型名等价。最后建议结构体不要定义在函数内部。
The text was updated successfully, but these errors were encountered: