main.cpp
#include <iostream>
#include <string>
using namespace std;
int main(int agrc, char *argv[]){
cout<<argv[0]<<endl;
cout<<argv[1]<<endl;
cout<<argv[2]<<endl;
cout<<argv[3]<<endl;
char a[4];
for(int i = 0; i <= 4; i++)
{
a[i] = *argv[i];//指针
}
for (int i =0; i<= 4; i++){
cout<<a[i]<<endl;
}
return 0;
}
CMakeLists.txt
project(mainAPP)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_STANDARD 11)
add_executable(main main.cpp)
调用
./main h ewf wef ewf