CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VC/MFC >  基础类

经常看到exit(1),exit(-1),exit(0),exit(status)的参数到底各代表啥意思?

楼主booming(信誉值由于系统错误导致)2005-01-01 16:37:38 在 VC/MFC / 基础类 提问

经常看到exit(1),exit(-1),exit(0),exit(status)的参数到底各代表啥意思? 问题点数:10、回复次数:5Top

1 楼canany1tellme(菜鸟c)回复于 2005-01-01 16:43:47 得分 0

没什么意思,一般来说exit的参数是进程的返回码,一般是错误码,0表示没有错误,不过你可以自己定义Top

2 楼hiiiiiijiang(等待毕业)回复于 2005-01-01 17:09:28 得分 2

The   exit   and   _exit   functions   terminate   the   calling   process.   exit   calls,   in   last-in-first-out   (LIFO)   order,   the   functions   registered   by   atexit   and   _onexit,   then   flushes   all   file   buffers   before   terminating   the   process.   _exit   terminates   the   process   without   processing   atexit   or   _onexit   or   flushing   stream   buffers.   The   status   value   is   typically   set   to   0   to   indicate   a   normal   exit   and   set   to   some   other   value   to   indicate   an   error.  
   
  Although   the   exit   and   _exit   calls   do   not   return   a   value,   the   low-order   byte   of   status   is   made   available   to   the   waiting   calling   process,   if   one   exists,   after   the   calling   process   exits.   The   status   value   is   available   to   the   operating-system   batch   command   ERRORLEVEL   and   is   represented   by   one   of   two   constants:   EXIT_SUCCESS,   which   represents   a   value   of   0,   or   EXIT_FAILURE,   which   represents   a   value   of   1.   The   behavior   of   exit,   _exit,   _cexit,   and   _c_exit   is   as   follows.  
   
  Function   Description    
  exit   Performs   complete   C   library   termination   procedures,   terminates   the   process,   and   exits   with   the   supplied   status   code.    
  _exit   Performs   “quick”   C   library   termination   procedures,   terminates   the   process,   and   exits   with   the   supplied   status   code.    
  _cexit   Performs   complete   C   library   termination   procedures   and   returns   to   the   caller,   but   does   not   terminate   the   process.    
  _c_exit   Performs   “quick”   C   library   termination   procedures   and   returns   to   the   caller,   but   does   not   terminate   the   process.    
   
   
  Example  
   
  /*   EXITER.C:   This   program   prompts   the   user   for   a   yes  
    *   or   no   and   returns   an   exit   code   of   1   if   the  
    *   user   answers   Y   or   y;   otherwise   it   returns   0.   The  
    *   error   code   could   be   tested   in   a   batch   file.  
    */  
   
  #include   <conio.h>  
  #include   <stdlib.h>  
   
  void   main(   void   )  
  {  
        int   ch;  
   
        _cputs(   "Yes   or   no?   "   );  
        ch   =   _getch();  
        _cputs(   "\r\n"   );  
        if(   toupper(   ch   )   ==   'Y'   )  
              exit(   1   );  
        else  
              exit(   0   );  
  }  
   
  Top

3 楼guangsan(丑草)回复于 2005-01-01 18:02:15 得分 4

就是一个指定的进程退出代码。如果是一个单一的程序,status是0,-1,1都一样使程序退出(不知道这个退出代码如何处理)。  
   
  如果是一个子进程,可以使用GetExitCodeProcess获得退出代码,然后进行处理。  
   
   
   
  但是在面向对象的环境中由于exit()和abort()不销毁对象请不要在面向对象环境中使用abort()和exit()。Top

4 楼liudaqin(&& || ! 路漫漫其修远兮)回复于 2005-01-02 09:30:21 得分 2

学习Top

5 楼angelcool(快乐需要创造)回复于 2005-01-02 09:42:58 得分 2

知识Top

相关问题

  • sz到底是什么单词的缩写???比如参数lpszClassName
  • TForm的构照函数的参数到底是什么?
  • 这样写参数到底什么意思?int ** &t
  • 参数传递到底是传值还是传地址
  • exit函数参数的问题?
  • [Q:]怎么使用URLDownloadToFile中的Status参数
  • SHGetFileInfo获取系统图标时,参数pszPath到底写什么好?
  • 请问BCB窗体函数都带个参数TObject *Sender到底是有何用?
  • CreateProcess的倒数第三个参数lpCurrentDirectory到底有什么作用啊?
  • java中如果对象是函数参数 到底是传值还是引用???

关键词

  • 代码
  • exit
  • 参数
  • 意思
  • 退出代码
  • 进程
  • status
  • process
  • terminates
  • ch

得分解答快速导航

  • 帖主:booming
  • hiiiiiijiang
  • guangsan
  • liudaqin
  • angelcool

相关链接

  • Visual C++类图书
  • Visual C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo