常看到 exit(8); 这个东西做什么用的啊??
通常在结尾~~~ 问题点数:20、回复次数:10Top
1 楼qrlvls( 空 气 )回复于 2004-12-03 21:30:00 得分 10
exit可以退出程序,8是退出代码,退出后在操作系统中可以进行判断,但是通常为0
例如DOS下有一个CHOICE的程序就是通过这种方法来实现的
在一个批处理文件中,可以判断CHOICE的返回值,以进行菜单选择Top
2 楼masse(当午 http://blog.sina.com.cn/xukf)回复于 2004-12-03 22:05:25 得分 0
似乎exit(0)更多一些,我没有见过exit(8),呵呵Top
3 楼idler(告别teenage)(偶是豆子。。。)(歇业休息。。。)回复于 2004-12-03 22:15:28 得分 5
qrlvls正解。通常返回非零值可以理解为非正常退出,其值代表错误类型。Top
4 楼wozhaole(乐乐)回复于 2004-12-03 23:31:03 得分 0
The exit function, declared in the standard include file STDLIB.H, terminates a C++ program.
The value supplied as an argument to exit is returned to the operating system as the program's return code or exit code. By convention, a return code of zero means that the program completed successfully.
Note You can use the constants EXIT_FAILURE and EXIT_SUCCESS, defined in STDLIB.H, to indicate success or failure of your program.
Issuing a return statement from the main function is equivalent to calling the exit function with the return value as its argument.
For more information, see exit in the Run-Time Library Reference.
Top
5 楼sunlu_eric(天使预备役)回复于 2004-12-04 10:58:32 得分 0
是,但具体每一个数值表示什么意思请解答!
Top
6 楼avalonBBS("︶.︶メ)→( ̄ε ̄メ)回复于 2004-12-04 11:09:28 得分 0
没有固定意思Top
7 楼sharkhuang(走吧走吧!人总会慢慢长大~)回复于 2004-12-04 13:34:25 得分 0
退出,返回值是8Top
8 楼sharkhuang(走吧走吧!人总会慢慢长大~)回复于 2004-12-04 13:35:24 得分 0
NAME
exit - end program execution
ANSI_SYNOPSIS
#include <stdlib.h>
void exit(int code);
TRAD_SYNOPSIS
#include <stdlib.h>
void exit( code)
int code;
DESCRIPTION
Use exit to return control from a program to the host
operating environment. Use the argument code to pass an
exit status to the operating environment: two particular
values, EXIT_SUCCESS and EXIT_FAILURE, are defined in `
stdlib.h' to indicate success or failure in a portable
fashion.
exit does two kinds of cleanup before ending execution of
your program. First, it calls all application-defined
cleanup functions you have enrolled with atexit. Second,
files and streams are cleaned up: any pending output is
delivered to the host system, each open file or stream is
closed, and files created by tmpfile are deleted.
RETURNS
exit does not return to its caller.
PORTABILITY
ANSI C requires exit, and specifies that EXIT_SUCCESS and
EXIT_FAILURE must be defined.
Supporting OS subroutines required: _exit.
SOURCE
src/newlib/libc/stdlib/exit.c
exit(3)
(END)Top
9 楼james930(Geek930)回复于 2004-12-14 20:45:52 得分 5
那这个返回值是返回到哪里去呢?有时候在主函数main()中有个if语句然后就是加上个exit(1)或者其他数的,那么这个数返回到哪里去呢?Top
10 楼jiangpeng(Mr. J)回复于 2004-12-14 20:54:49 得分 0
返回到父进程Top
相关问题
- 在www.263.net经常看到在线游戏一些的东西,这些游戏是用JAVA写的。
- 这几个东西经常看到,请大家给我讲一下。越详细越好!
- trace 输出的东西在那里可以看到
- ●●在这里看到这样的东西很是不爽!!
- ******输入 http://jilinbdgs.126.com 把看到的东西告诉我 ,我给你20分!!!*************
- 老是看到Q1345,QXXXXX什么之类的东西,这是代表什么?
- 偶看到SOAP,不知道在JAVA里有哪些东西与此有关?
- 看到N多人在谈论NHibernate,可是我不知道是什么东西:(
- 刚才看到的一个不错的东西,50楼以后给答案
- 看到不少网页上有天气预报的东西,怎么实现的?




