Why a warning of “control reaches end of non-void function” for the main function?

后端 未结 3 952
野性不改
野性不改 2021-02-18 17:25

I run the following C codes and got a warning: control reaches end of non-void function

int main(void) {}

Any suggestions?

3条回答
  •  心在旅途
    2021-02-18 17:56

    The main function has a return-type of int, as indicated in

    int main(void)
    

    however your main function does not return anything, it closes after

    puts(strB);
    

    Add

    return 0;
    

    after that and it will work.

提交回复
热议问题