#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
int main(int argc,char *argv[])
{
int i;
for (i = 0; i < argc; i++)
{
cout << "argument" << i << ": " << argv[i] << endl;
}
cout << "total argument:" << argc;
return EXIT_SUCCESS;
}
执行:
g++ test.cpp -o test
./test 3 3 5 9
argument0: ./test
argument1: 3
argument2: 3
argument3: 5
argument4: 9