http://www.site.uottawa.ca/~lucia/courses/2131-05/labs/Lab3/CommandLineArguments.html
You’ll notice that argv[0] is the path and name of the program itself.
This allows the program to discover information about itself.
char *argv []是一个字符数组,其大小是int argc
argc是命令行总的参数个数
argv []是argc的参数,其中第0 个参数是程序的全名,以后的参数是命令行后面跟的用户输入的参数,比如:
int main(int argc, char* argv [])
{
int i;
for (i = 0 ; i<argc; i++)
cout<<argv [i]<<endl;
cin>>i;
return 0 ;
}
执行时敲入
F:/MYDOCU~1/TEMPCODE/D1/DEBUG/D1.EXE aaaa bbb ccc ddd
输出如下: