Programming Reference/Librarys
Question & Answer
Q&A is closed
#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 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; }
user@host:~$ ./exit 0 1 2
user@host:~$ ./exit