“返回0"与“返回0"之间的差异和“退出(0)"; [英] Difference between "return 0" and "exit (0)"

查看:125
本文介绍了“返回0"与“返回0"之间的差异和“退出(0)";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在函数中使用时,return 0exit (0)之间是否有区别? 如果是,我应该何时在函数中使用return 0exit (0)?

Is there any difference between return 0 and exit (0) when using in a function? If yes, When should I use return 0 or exit (0) in a function?

推荐答案

return从函数中退出,而exit从程序中退出.

return exits from the function while exit exits from the program.

main函数中执行return 0;语句或调用exit(0)函数将调用已注册的atexit处理程序,并导致程序终止.

In main function executing return 0; statement or calling exit(0) function will call the registered atexit handlers and will cause program termination.

这篇关于“返回0"与“返回0"之间的差异和“退出(0)";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆