如何将 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 字符串std::string
with c_str()
:
system(("start " + app).c_str());
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)