第1个回答 2016-01-08
#include <iostream>
using namespace std;
int main(int argc,char *argv[])
{
cout<<"参数个数:"<<argc<<endl;
cout<<"循环打印命令行参数:"<<endl;
while (argc != 0)
{
cout<<""<<argv[argc-1]<<endl;
argc--;
}
return 0;
}
需要生成一个exe文件之后,在命令行运行那个exe,如
path\test.exe hello world
其中hello world是参数