2
下面是一个程序,我写了一个运行良好的时候我型我想要的Linux命令它执行Linux系统功能
include iostream
include string
using namespace std;
int main()
{
cout << "The directory!";
system("cd CS_204");
return 0;
}
不过下面我试图使它这样用户就可以在命令中键入他们想要的,我得到他们不能转换std::string
到const char*
这是我第一次使用该功能,我拼命试图了解它。帮帮我!!
int main()
{
cout << "The directory!";
string word;
cin >> word
if(word != "A")
system(word);
return 0;
}
谢谢你们两个了获得C风格的字符串,我会记得把它标记为功课下次对不起!但是,谢谢! – CIM