Nếu không dùng function prototype, và thân hàm định nghĩa sau lời gọi. Trình biên dịch mặc định kiểu trả về là int. Nếu hàm trả về kiểu khác, báo lỗi. Nếu trả về int, chạy được (có thể có warning).
Ví dụ lỗi
#include <stdio.h>
int main() {
printf("The returned value: %d\n", function);
}
char function() {
return 'T';
}
Kết quả
[Error] conflicting types for 'function' [Note] previous implicit declaration of 'function' was here
Ví dụ đúng (trả về int)
#include <stdio.h>
int main() {
printf("The returned value: %d\n", function());
}
int function() {
return 86;
}
Kết quả
The returned value: 86