38>>int Main (int argc, char **argv)

Source: Internet
Author: User
1. Parameters

(sometimes the parameter is void)

ARGC is the number of parameters when the program runs

ARGV is an array of stored parameters, which can be used with char* argv[] or char **argv.

For example, compiling a hello.c program

1 #include <stdio.h>
2 int main (int argc,char *argv[])
3 {
4 printf ("%d\n", argc);
5 printf ("%s\n", argv[0]);
6/*printf ("Hello World");
7 return 0;
8}
Compile run:./hello hehe

Results:

2

./hello

If the output is argv[1], the hehe is output.

2, int

This is often the case where the return type of the main function definition is int (not void), and there is no return 0 at the end of the function; This statement is strange.

38>>int Main (int argc, char **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.