C ++ primer -- Main Function

Source: Internet
Author: User

It's hard to start with everything. Let's start with the main function.

1. Each C ++ProgramMust contain the main function

2. The operating system calls the main function to execute the program, and the main function is the only function shown and called by the operating system.

3. In most systems, the return value of the main function is a status indicator. If 0 is returned, the execution is successful. Other non-zero return values have their own definitions for each operating system.

When you want to introduce the parameters of the main function, you cannot see the relevant introduction. When you are wondering, you can see a small note in this article: Section 7.2.6 describes other parameters that can be defined in the main function. So go there:

Main function with parameters:

Int main (INT argc, char * argv [])

{........

}

It can also be expressed:

Int main (INT argc, char ** argv)

{........

}

Argc indicates the number of strings in the argv array. The first element of argv is usually the name of the program. The following elements pass additional strings to main. For example:

Argv [0] = "prog"

Argv [1] = "-d"

...........

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.