The main function provides a reference prototype such as:
int _tmain(int argc, _TCHAR* argv[])
{
for(int i=0;i<argc;i++)
_tprintf(_T("%s\n"),argv[i]);
return 0;
}
或者如:
int main(int argc, char **argv)
{
}
Linux for:
#include "/usr/include/stdio.h"
int main(int argc, char **argv)
{
int i=0;
for(i=0;i<argc;i++)//不支持在for语句中嵌套定义
printf("%s\n",argv[i]);
return 0;
}
>
The rationale is the same, ARGC represents the number of arguments (the numbers of strings separated by spaces), argv is a set of string arrays, passed in by the command line, Argv[0] is the file name for the command line itself, Argv[1 is the first argument, and so on.
In the first procedure above, output all command-line arguments sequentially (the first line output command itself).
Note: Although it is original, but the technical content is limited, but I learn some of the program design history records, if there are improper places welcome exchanges. This kind of article is not what I am good at, must not take my idea as the conclusion.
This article is from the "Tommy (Data Recovery)" blog, please be sure to keep this source http://zhangyu.blog.51cto.com/197148/153991