User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







c:stdlib.h:exit
click
to support this page (eg 0,42 € or so) Thanks.

exit

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

exit causes the termination of a program.
To the environment in which the program was started, a return code will be sent.

exit C Sourcecode Example

/* 
 * exit c example code
 * http://code-reference.com/c/stdlib.h/exit 
 */
#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
 
#include <stdlib.h>
 
int exittest ( int testval )
{
   if (testval == 3 ) {  exit (1); }
return 0;
}
 
int main( void )
{
 int i;
 
/* comment this in to see what happen */
// exit(0); 
 
 for (i=0;i<=99;i++) {
     exittest(i);
     printf("%i\n", i);
  }
 
return 0;
}

Output with commented exit(0) before the for loop

  user@host:~$ ./exit
  0
  1
  2

Output with out commented exit(0) before the for loop

  user@host:~$ ./exit
advertising
c/stdlib.h/exit.txt · Last modified: 2013/09/17 04:14 by 2001:da8:208:125:88e8:be7a:5118:9d37

Impressum