Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ Language Reference - exit http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
   exit

   Usage
   #include <stdlib.h>
   void exit(int exitstatus);

   Description
   exit calls functions logged by atexit, all static destructors (for C++
   programs),  flushes  all output buffers, closes all output  files  and
   returns to MSDOS with an exit status given by exitstatus. exit is  the
   preferred function for C++ programs.

   exitstatus  is  normally a EXIT_SUCCESS to indicate a  normal  end  of
   program  and EXIT_FAILURE to indicate an error. Only the  lower  order
   byte of exitstatus is returned to the parent process. The exit  status
   can  be  referenced by the name ERRORLEVEL in batch files and  by  the
   spawn return values.

   Example
   #include <stdlib.h>
   #include <stdio.h>
   main(int argc,char *argv[])
   {
   FILE *fp;
        if(argc > 1)
        {
             fp = fopen(argv[1],"r");
             if(fp == NULL)
             {
                  fprintf(stderr,"Can't open \"%s\"\n", argv[1]);
                  exit(EXIT_FAILURE);
             }
        }
        else
        {
             fprintf(stderr,"No file specified\n");
             exit(EXIT_FAILURE);
        }
        return (EXIT_SUCCESS);
   }

See Also: abort exit spawn

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson