C中的隐式返回类型int

如果某个函数没有返回类型,则返回类型将隐式为int。如果不存在返回类型,则不会产生任何错误。但是,C99版本不允许省略返回类型,即使它是int。

示例

#include<stdio.h>
my_function(int x) {
   return x * 2;
}
main(void) {
   printf("Value is: %d", my_function(10));
}

输出结果

Value is: 20