System Call using Paremeters

Hey guys , i need your help regarding calling of an executable. What i am trying to do is to call an executable with parameters in order for it to generate a result for me. Currently , my coding is like this...

Code:

system ("a-s123);



"a" is the executable while "-s123" is the parameters needed to make it generate the output i want. The problem i am facing is that the paremeters in which i use is based on the information stored in a variable.

For example
1
2
3
4
5
	int main ()
 {
	string b = "-s123"
	system ("a "(b)) ;
	}




this is an example of what i mean , but obviously it isnt working. Is there any way i can go about passing a variable as a parameter into the executable to help it generate the output i am looking for?
1
2
3
string b = "-s123";
string c = "a " + b;
system(c);
Last edited on
newmain.cpp:17: error: cannot convert `std::string' to `const char*

this was the error i got.I am not sure why but i guess its because system() needs a "" in between the brackets to state the executable you want to run. If i were to put it as system("c") , it wouldnt run as there is no such executable.
It must be system(c.c_str());
Sorry for that, im a noob when it comes to the standard classes ._.'
Topic archived. No new replies allowed.