更新时间:2023-02-20 11:31:37
添加头文件< stdlib.h>
喜欢,
Add header file <stdlib.h>
like,
#include <stdlib.h>
例如,
For Example,
#include <stdlib.h>
int main( void )
{
exit( 0 );
}
注意
Regards
在旁注中,除非程序遇到错误情况并且不能确保所有对象仍处于定义良好的状态,否则不应使用exit.从程序返回的首选方法是在main()
中调用return
.参见> http://***.com/questions/461449/return-statement-vs-exit -in-main [ ^ ]
并不是说您使用的是错误的,但是解决方案2中的示例就是这种类型的-该代码应使用return
而不是exit
.
On a sidenote, you shouldn''t use exit unless your program ran into an error condition and you can not be sure all your objects are still in a well-defined state. The preferred way of returning from a program, is to callreturn
inmain()
. See http://***.com/questions/461449/return-statement-vs-exit-in-main[^]
Not saying you are using it wrong, but the example in Solution 2 is of that type - that code should usereturn
rather thanexit
.