C++ c+;的用户定义目录+;要从中执行的系统函数
我发现这一点,但这不起作用,因为我的代码看起来像这样C++ c+;的用户定义目录+;要从中执行的系统函数,c++,system,C++,System,我发现这一点,但这不起作用,因为我的代码看起来像这样 system("mkdir C:\\Users\\USER\\Desktop\\test"); string inputFAT=“input.FAT”; 字符串outputdirectry=“adirectory”; 字符串exepath=“FATool.exe”; cout传递给system()的参数错误: string inputFAT = "input.FAT"; string outputdirecotry = "adire
system("mkdir C:\\Users\\USER\\Desktop\\test");
string inputFAT=“input.FAT”;
字符串outputdirectry=“adirectory”;
字符串exepath=“FATool.exe”;
cout传递给system()
的参数错误:
string inputFAT = "input.FAT";
string outputdirecotry = "adirectory";
string exepath = "FATool.exe";
cout << "enter the directory you would like to have the files put out to";
getline(cin, outputdirecotry);
string outputdirectorycommand = "cd " + outputdirecotry;
cout << "enter the path of the file you want to extract";
getline(cin, inputFAT);
cout << "enter the path to the FATool executable";
getline(cin, exepath);
string exportcommand = exepath + " -x " + inputFAT;
system(outputdirectorycommand.c_str && exportcommand.c_str());
语法outputdirectorycommand.c_str
错误,传递给system()
的参数是bool
,这显然是错误的
假设您要执行的是执行cd&&FATool.exe-x
,那么您应该cat
您的命令并将其传递给system()
:
传递给system()
的参数错误:
string inputFAT = "input.FAT";
string outputdirecotry = "adirectory";
string exepath = "FATool.exe";
cout << "enter the directory you would like to have the files put out to";
getline(cin, outputdirecotry);
string outputdirectorycommand = "cd " + outputdirecotry;
cout << "enter the path of the file you want to extract";
getline(cin, inputFAT);
cout << "enter the path to the FATool executable";
getline(cin, exepath);
string exportcommand = exepath + " -x " + inputFAT;
system(outputdirectorycommand.c_str && exportcommand.c_str());
语法outputdirectorycommand.c_str
错误,传递给system()
的参数是bool
,这显然是错误的
假设您要执行的是执行cd&&FATool.exe-x
,那么您应该cat
您的命令并将其传递给system()
:
这将尝试获取std::string::c_str函数的地址,将其转换为bool和logical,并使用exportcommamd.c_str()返回值的bool转换对其进行测试
你可能是有意的
system(outputdirectorycommand.c_str && exportcommand.c_str());
这将尝试获取std::string::c_str函数的地址,将其转换为bool和logical,并使用exportcommamd.c_str()返回值的bool转换对其进行测试
你可能是有意的
system(outputdirectorycommand.c_str && exportcommand.c_str());
哇,好的,谢谢,我从来没有教过这样做,现在看起来很明显哇,好的,谢谢,我从来没有教过这样做,现在看起来很明显,我想这也行,但是我认为第一个答案是阻力最小的道路仍然值得投票,虽然我想这也行,但是我认为第一个答案是阻力最小的道路不过,抵抗运动仍然值得投票表决
system(outputdirectorycommand.c_str() + " && " + exportcommand.c_str());