GCC C compiler warning "warning: control reaches..."

This question already has an answer here:

  • What should main() return in C and C++? 19 answers

  • 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的默认行为,现在你只需返回一些东西。

    链接地址: http://www.djcxy.com/p/73604.html

    上一篇: 这段代码如何打印404?

    下一篇: GCC C编译器警告“警告:控制到达...”