Exit seems to be in the "stdlib. H" header file, so it must contain the header file
Return indicates a function call. If the main function is returned, the system exits the program.
Exit is to forcibly exit the program at the call. Once the program is run, it will end.
Exit (1) indicates an abnormal exit. This 1 is returned to the Operating System
Exit (0) indicates normal exit
Numbers 0, 1 and-1 are written to the environment variable errorlevel. Other programs can determine the end state of the program.
Generally, 0 is normal, and other numbers are abnormal. You can specify the corresponding error.
-------------------------------------------------------------------
If it is returned to the operating system, 0 indicates normal exit, and other values indicate abnormal exit. Before exiting, You can provide some prompt information or check the cause of the error in the debugging program.
1 # include "iostream. H"
2 # include "stdlib. H"
3 void fun ()
4 {
5 int * P;
6 if (P = new INT) // If P is assigned to the space, continue to execute (very rogue writing)
7 {
8 * P = 5;
9 cout <* P <Endl;
10 Delete P;
11}
12 else
13 {
14 cout <"heap error" <Endl;
15}
16}
17 void main ()
18 {
19 fun ();
20 int * pA;
21 pA = new int [5];
22 if (! Pa) // if no space is allocated, call exit (1) to exit the program.
23 {
24 cout <"heap error" <Endl;
25 exit (1 );
26}
27 For (INT I = 0; I <5; I ++)
28 pa [I] = I + 1;
29 for (I = 0; I <5; I ++)
30 cout <pa [I] <"";
31 cout <Endl;
32 Delete [] Pa;
33}
From http://hi.baidu.com/zs1002229/blog/item/45ec5a4cd7de06c0d0c86ad1.html