gpt4 book ai didi

c - exit()函数的使用

转载 作者:太空狗 更新时间:2023-10-29 16:14:55 25 4
gpt4 key购买 nike

我想知道如何以及何时可以像我书中的程序一样使用exit()函数:

#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");
}

当我运行它时,它显示 ERROR: call to undefined function exit()

另外,我想知道如何创建一个选项来关闭程序运行的窗口?例如,我制作了一个菜单驱动程序,它有几个选项,其中之一是“退出菜单”。我怎样才能让它退出程序(即关闭窗口)?

最佳答案

尝试使用 exit(0);反而。 exit 函数需要一个整数参数。别忘了 #include <stdlib.h> .

关于c - exit()函数的使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2425167/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com