|
|
1.1 root 1:
2:
3: main() C Language main()
4:
5:
6:
7:
8: Introduce program's main function
9:
10:
11: A C program consists of a set of functions, one of which must be
12: called main. This function is called from the runtime startup
13: routine after the runtime environment has been initialized.
14:
15: Programs can terminate in one of two ways. The easiest is simply
16: to have the main routine return. Control returns to the runtime
17: startup; it closes all open file streams and otherwise cleans up,
18: and then returns control to the operating system, passing it the
19: value returned by main as exit status.
20:
21: In some situations (errors, for example), it may be necessary to
22: stop a program, and you may not want to return to main. Here,
23: you can use exit; it cleans up the debris left by the broken
24: program and returns control directly to the operating system.
25:
26: A second exit routine, called _exit, quickly returns control to
27: the operating system without performing any cleanup. This
28: routine should be used with care, because bypassing the cleanup
29: will leave files open and buffers of data in memory.
30:
31: Programs compiled by COHERENT return to the program that called
32: them; if they return from main with a value or call exit with a
33: value, that value is returned to their caller. Programs that in-
34: voke other programs through the ssyysstteemm function check the
35: returned value to see if these secondary programs terminated suc-
36: cessfully.
37:
38: ***** See Also *****
39:
40: _exit, argc, argv, C language, envp, exit
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64: COHERENT Lexicon Page 1
65:
66:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.