熵增为什么绝望:c语言中怎么使整个程序退出(悬赏20)

来源:百度文库 编辑:高校问答 时间:2024/05/06 04:49:41
据说可以用EXIT函数,但不知道具体如何使用,希望高手们能帮帮忙;谢谢

函数名: exit
功 能: 终止程序
用 法: void exit(int status);
程序例:

#include <stdlib.h>
#include <conio.h>
#include <stdio.h>

int main(void)
{
int status;

printf("Enter either 1 or 2\n");
status = getch();
/* Sets DOS errorlevel */
exit(status - '0');

/* Note: this line is never reached */
return 0;
}

程序执行了RETURN 就会自动终止
int main(int argc, char * argv[])
{
if(2 != argc) {exit(0);}

return 0;
}
GOOD LUCK
用软件改变世界,用代码书写人生,用思想创造未来!

在main()函数里使用return就可以了
楼上的也行

system("exit"); 执行DOS命令exit;