linux 下c/c++中使用shell命令的格式为: system("ls -l");
将命令得到结果结果保存的一种方式是: system("ls -l >result.txt");
若想使用参数作为传入命令中,使用string:
string resultTXT = "result.txt";
string command = "ls -l >" + resultTXT ;
system(command.c_str());
linux 下c/c++中使用shell命令的格式为: system("ls -l");
将命令得到结果结果保存的一种方式是: system("ls -l >result.txt");
若想使用参数作为传入命令中,使用string:
string resultTXT = "result.txt";
string command = "ls -l >" + resultTXT ;
system(command.c_str());