Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我见过一个可以打印自己的程序,如下所示:
main(a){printf(a,34,a="main(a){printf(a,34,a=%c%s%c,34);}",34);}
我的问题是:为什么它可以在a不指定任何类型的情况下传递一个main函数?我知道main函数的参数是voidor argc, argv。那么,a这里的意思是什么?
a
main
void
argc, argv
这是 C (K&R, C89) 的隐式 int特性。如果您遗漏了类型,int则由解析器假定。IIRC 它在 C99 中被标记为已过时。它还允许您编写声明,例如
int
static foo; /* static int foo; */