C++ linux系统功能
下面是我编写的一个程序,当我键入希望它执行的linux命令时,它运行良好C++ linux系统功能,c++,C++,下面是我编写的一个程序,当我键入希望它执行的linux命令时,它运行良好 include iostream include string using namespace std; int main() { cout << "The directory!"; system("cd CS_204"); return 0; } 在第二种情况下,word的类型为std::string,并不等同于const char*。您需要使用member函数获取c样
include iostream
include string
using namespace std;
int main()
{
cout << "The directory!";
system("cd CS_204");
return 0;
}
在第二种情况下,
word
的类型为std::string,并不等同于const char*。您需要使用member函数获取c样式的字符串
非常感谢你们两位,下次我会记得把它标记为家庭作业的。对不起!但是谢谢!!!
int main()
{
cout << "The directory!";
string word;
cin >> word
if(word != "A")
system(word);
return 0;
}
system(word.c_str()); // This will convert to a c style string.