C language Function Encyclopedia (beginning of M)

Source: Internet
Author: User
Tags command line first string

Main () Primary function

Every C program must have a main () function that can be placed somewhere in the program according to your hobby. Some programmers put it first, while others put it on the last side, no matter where it is, the following instructions are appropriate.

1.main () parameter

During the turbo C2.0 boot process, pass the main () function three parameters: ARGC, argv, and Env.

* ARGC: Integer, for the number of command line arguments passed to main ().

* argv: Array of strings.

In the DOS 3.X version, argv[0] is the full path name for the program to run; To DOS 3.0

The following version, Argv[0] is an empty string ("").

ARGV[1] is the first string after the execution of the program name on the DOS command line;

ARGV[2] is the second string after the execution of the program name;

...

ARGV[ARGC] is null.

*env: An Fu string array. Every element of env[] contains characters of envvar=value form

String. Where Envvar is an environment variable such as path or 87. Value is envvar corresponding to C:\DOS, C:

\TURBOC (for path) or Yes (for 87).

Turbo C2.0 always passes these three parameters to the main () function when it is started, and can be used in the user program

Descriptions (or not) of them, and if some (or all) of the parameters are described, they become main () subroutines

The local variable.

Please note that once you have indicated these parameters, you must press ARGC, ARGV, env order, as follows

Examples of:

Main ()

Main (int argc)

Main (int argc, char *argv[])

Main (int argc, char *argv[], char *env[])

The second of these is legal, but not common, because there are very few argc in the program, not

In the case of argv[].

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.