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

前端 未结 8 1653
渐次进展
渐次进展 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:54

    In C++ it would be a compile error to return anything other than int from main():

    error: ‘::main’ must return ‘int’
    

    In C it is a warning, you will get a float reinterpreted as an int: for example, 2.1F would be reinterpreted as 224.

提交回复
热议问题