我是C的新手(我之前有Java,C#和一些C++经验).在C中,是否有必要声明一个函数原型,或者代码可以在没有它的情况下编译?这样做是很好的编程习惯吗?或者它只是依赖于编译器?(我正在运行Ubuntu 9.10并在Code :: Blocks IDE下使用GNU C编译器或gcc)
为什么这段代码有效:
#include <stdio.h>
int main()
{
int x = isspace(getchar());
printf("%d", x);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
每当我输入whitespace isspace()返回8时,当我不输入时,它返回0.
这不应该在编译时产生错误吗?我没有#include <ctype.h>在顶部添加.那么为什么允许这样做呢?