#include <stdio.h>
main()
printf();
预处理器和函数之间有什么联系?
最佳答案
当 C 预处理器读取行 #include <stdio.h>
时, 它从字面上读取文件 stdio.h
从系统目录并用内容替换此行。然后 stdio.h
包含 printf
的声明和其他函数,告诉 C 编译器这些函数存在于另一个文件或库中。
当您使用 printf()
时在你的代码中,编译器知道这个函数并且知道它不必担心它。 (但是,如果您不包含 stdio.h
,编译器根本不知道该函数是什么样的,这可能会很麻烦,并且编译器会对此进行提示。)
一个例子 stdio.h
文件 printf
可能看起来像这样:
/* stdio.h */
// Declaration of printf
int printf(const char *format, ...);
// And also a bunch of other function declarations...
关于c - #include <stdio.h> 和 printf() 有什么关系?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23177385/