1. 简单的读取命令行参数
test.cpp
#include <iostream>
using namespace std;
int main(int argc, char **argv) {
for(int i=0; i<argc; i++){
cout << argv[i] << " ";
}
cout<<endl;
return 0;
}
运行以下命令:
clang++ test.cpp -o test
./test argu1 argu2
输出的结果为:
./test argu1 argu2