#include <stdio.h> //I want this same code to work without including this line int main () { char str [80]; scanf ("%s",str); return 0; }
extern int scanf(const char *format,...);
extern关键字是可选的,但我喜欢将其包含在内,以提醒函数在其他地方定义.
您的示例将如下所示:
extern int scanf(const char *format,...); int main () { char str [80]; scanf ("%s",str); return 0; }