This question already has answers here:
What is the difference between exit and return? [duplicate]
(4个答案)
6年前关闭。
在函数中使用
如果是,我应该何时在函数中使用
(4个答案)
6年前关闭。
在函数中使用
return 0
和exit (0)
之间有什么区别吗?如果是,我应该何时在函数中使用
return 0
或exit (0)
? 最佳答案
return
从函数中退出,而exit
从程序中退出。
在main
函数中,执行return 0;
语句或调用exit(0)
函数将调用已注册的atexit
处理程序,并导致程序终止。
关于c - “return 0”和 “exit (0)”之间的区别,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17383015/