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
廣告
如果某個函式沒有返回型別,那麼返回型別將隱式地為 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