|
|
coherent
main() C Language main() Introduce program's main function A C program consists of a set of functions, one of which must be called main. This function is called from the runtime startup routine after the runtime environment has been initialized. Programs can terminate in one of two ways. The easiest is simply to have the main routine return. Control returns to the runtime startup; it closes all open file streams and otherwise cleans up, and then returns control to the operating system, passing it the value returned by main as exit status. In some situations (errors, for example), it may be necessary to stop a program, and you may not want to return to main. Here, you can use exit; it cleans up the debris left by the broken program and returns control directly to the operating system. A second exit routine, called _exit, quickly returns control to the operating system without performing any cleanup. This routine should be used with care, because bypassing the cleanup will leave files open and buffers of data in memory. Programs compiled by COHERENT return to the program that called them; if they return from main with a value or call exit with a value, that value is returned to their caller. Programs that in- voke other programs through the ssyysstteemm function check the returned value to see if these secondary programs terminated suc- cessfully. ***** See Also ***** _exit, argc, argv, C language, envp, exit COHERENT Lexicon Page 1
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.