Main function of process environment

Source: Internet
Author: User

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/.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.