Three forms of the C language main function

Source: Internet
Author: User

in the C language, Main () there are three forms of the function.

1 , no parameters

#include <stdio.h>int main (void) {   printf ("Hello world!\n");   return 0;}

2 , there are two parameters

The first parameter is the integral type ARGC argv , saved as a string with The corresponding parameters, such as the following example:

#include <stdio.h>int main (int argc, char* argv[]) {   int i = 0;   for (; i < argc; i++) {       printf ("%s\n", Argv[i]);   }   printf ("Hello world!\n");   return 0;}

3 , there are three parameters

ARGC and argv env= Value " , the parameter type is an array of pointers or a level two pointer, as in the following example:

int main (int argc, char* argv[], char* envp[]) {    int i = 0;    for (; Envp[i]! = ' + '; i++) {        printf ("%s\n", Envp[i]);    }    printf ("Hello world!\n");    return 0;}



Three forms of the C language main function

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.