出口的使用()函数 [英] Use of exit() function
问题描述
我想知道如何以及什么时候可以使用退出()
就像在我的书的程序功能:
I want to know how and when can I use the exit()
function like the program in my book:
#include<stdio.h>
void main()
{
int goals;
printf("enter number of goals scored");
scanf("%d",&goals);
if(goals<=5)
goto sos;
else
{
printf("hehe");
exit( );
}
sos:
printf("to err is human");
}
当我运行它,它会显示错误:调用未定义的函数的exit()的
When I run it, it shows ERROR: call to undefined function exit().
另外,我想知道我怎么可以创建一个选项,关闭该程序运行的窗口?例如,我做了一个菜单驱动程序,它有几种选择,其中之一是的退出菜单的。我怎样才能让这个退出程序(即关闭窗口)?
Also, I want to know how I can create an option to close the window in which the program runs? For example, I made a menu-driven program which had several options and one of them was "exit the menu". How can I make this exit the program (i.e. close the window)?
推荐答案
尝试使用退出(0);
来代替。该 退出
函数期望的整数参数。而且不要忘了的#include&LT;文件stdlib.h方式&gt;
Try using exit(0);
instead. The exit
function expects an integer parameter. And don't forget to #include <stdlib.h>
.
这篇关于出口的使用()函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!