我想在C中使用printf()函数打印一些东西,而不包括stdio.h,所以我编写了程序:
int printf(char *, ...);
int main(void)
{
printf("hello world\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
以上程序是否正确?
CB *_*ley 18
正确的声明(ISO/IEC 9899:1999)是:
int printf(const char * restrict format, ... );
Run Code Online (Sandbox Code Playgroud)
但这对于公正而言是最简单和最安全的#include <stdio.h>.
peo*_*oro 12
只是:
man 3 printf
Run Code Online (Sandbox Code Playgroud)
它会告诉你printf签名:
int printf(const char *format, ...);
Run Code Online (Sandbox Code Playgroud)
这是正确的.