需不需要返回值看你的方法你的方法int main就是要返回一个整形,比如说return 0
你的方法void main就是不需要返回值,就不需要写return
C/C++中main
函数比较特殊,如果main
中return
语句被省略,那么它等价于return 0;
。
https://en.cppreference.com/w/c/language/main_function
If the return type is compatible with int and control reaches the terminating }, the value returned to the environment is the same as if executing return 0;.