Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/162.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ c+;的用户定义目录+;要从中执行的系统函数_C++_System - Fatal编程技术网

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());