GCC C compiler warning "warning: control reaches..."
This question already has an answer here:
Your main function doesn't explicitly return anything. Just slap a return 0;
at the end and you should be OK:
int main()
{
char s1[] = "abcd";
char s2[] = "zzzz";
contract(s1,s2);
return 0; /* Here! */
}
The -ansi
option switches to the ISO C90 standard. Back then, the main
function had to return something. Since C99, it's OK to leave out the return statement.
当使用-ansi
(= C89)时,如果你不返回任何东西 - 你定义了一个非void的返回类型(int),那么你不会得到返回0的默认行为,现在你只需返回一些东西。
上一篇: 这段代码如何打印404?