如何将一个c++变量数据放入system()函数中?
看下面的代码:
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
cout << "name the app u want to open";
string app;
cin >> app;
system("start app"); // I know this will not work! But how to make it will?
return 0;
}
最佳答案
连接两者,然后使用c_str()
从std::string
中获取C字符串:
system(("start " + app).c_str());
关于c++ - 如何将 C++ 变量数据放入 system() 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41242820/