tintin
tintin

Reputation: 1

how can I use string variable in system("say string variable")?

/* I thought of doing in this way, but it invalid. so any help will be appreciated. */

#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;
}

Upvotes: 0

Views: 68

Answers (1)

user8633839
user8633839

Reputation:

You can use:

system(("say" + sums).c_str())

Instead of:

system("say %s", sums)

Upvotes: 2

Related Questions