Passing arguments in system()

C

Chris

I am having trouble with system() in a c++ application I am trying to
link to a robotic arm:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
string movement= "move arm right";
system("C:\\Program Files\\ATTLABS\\NATURAL VOICES\\VoiceCommand /
text= movement /voice=\"AT&T Natural Language Mike\"");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I am trying to use system() to start an AT&T app (VoiceCommand) with
the arguments /text="" and /voice="".

Could someone give me a heads up of what a better function or way to
use system() may be?

Thank you very much for your time.
 
R

red floyd

I am having trouble with system() in a c++ application I am trying to
link to a robotic arm:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
string movement= "move arm right";
system("C:\\Program Files\\ATTLABS\\NATURAL VOICES\\VoiceCommand /
text= movement /voice=\"AT&T Natural Language Mike\"");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I am trying to use system() to start an AT&T app (VoiceCommand) with
the arguments /text="" and /voice="".

Could someone give me a heads up of what a better function or way to
use system() may be?

Thank you very much for your time.

Build up the command externally, and pass the result to system().

std::eek:stringstream ss;
ss << "C:\\Program Files\\ATTLABS\\NATURAL VOICES\\VoiceCommand"
<< " /text=\"move arm right\""
<< /voice=\"AT&T Natural Language Mike\"";
system(ss.str().c_str());
 
F

Fred Zwarts

Chris said:
I am having trouble with system() in a c++ application I am trying to
link to a robotic arm:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
string movement= "move arm right";
system("C:\\Program Files\\ATTLABS\\NATURAL VOICES\\VoiceCommand /
text= movement /voice=\"AT&T Natural Language Mike\"");

Note that "movement" is taken here literally. It is not the string variable you declared earlier.
As said already in the other respons, it may be better to construct the string
in one or more lines of code and than pass it to system ().
In that way you can also print the string for debugging to verify what is passed to system ().
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,123
Latest member
Layne6498
Top