0
/*我想這樣做,但它是無效的。 所以任何幫助將不勝感激。 */如何在系統中使用字符串變量(「say string variable」)?
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name = "Karma";
string greet = "How was your day?";
string sums = name + greet;
system("say %s", sums) // not working
// system("say sums") not working
return 0;
}
'系統(( 「說」 +資金).c_str());' – HolyBlackCat
也「[爲什麼「使用命名空間標準」被認爲是不好的做法?](https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice)「。 – HolyBlackCat
'system'接受一個指向常量字符串而不是'class string'的指針。 – Raindrop7