What happens if main() does not return an int value?

前端 未结 8 1667
渐次进展
渐次进展 2020-12-03 03:19

I know that in C compilers the main() function is called by the _start() function which has code something like this:

exit(main());         


        
8条回答
  •  忘掉有多难
    2020-12-03 03:58

    The function will return an implementation-defined value. For example, in C++, main implicitly returns 0. In this case of a void main then this would simply be returned by _start. However, there are virtually no implementations that would allow any arbitrary return type- it's baked into the operating system that a process exits with an integral value.

提交回复
热议问题