C Programs are always executed from the main function. The main function is prototype:
Main (argc, * argv []);
Here, argc is the number of command line parameters, and argv is an array composed of pointers to parameters.
When the kernel executes a C program (using an exec function), it calls a special startup routine before calling main. The executable program file specifies this startup routine as the starting address of the program-this is set by the connection editor, and the connection editor is called by the C compiler (usually cc. The startup routine obtains the command line parameters and environment variable values from the kernel, and makes arrangements for calling the main function as described above.
This blog is excerpted from advanced programming for UNIX environments (version 2) and used only for personal learning records. For more information about this book, see:Http://www.apuebook.com/.