Hello everybody!

I build a string for a system call (Matlab) like:

std::string command = "matlab -nosplash -r MyMatlabScript(" + arg1 + " " + arg2 + ");";

The system call is:

system(command.c_str());

However, i get an error, pointing to the first parentheses in my command string.

How can i use a "(" sign in my system call?

Thanks a lot,

#EO

I used Windows 7 and did not have a problem with that code snippet,

#include <string>
using std::string;

int main(int argc, char**argv)
{
	string arg1 = "one";
	string arg2 = "two";
	string command = "matlab -nosplash -r MyMatlabScript(" + arg1 + " " + arg2 + ");";
	system(command.c_str());
}
'matlab' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . .

I used Windows 7 and did not have a problem with that code snippet,

#include <string>
using std::string;

int main(int argc, char**argv)
{
	string arg1 = "one";
	string arg2 = "two";
	string command = "matlab -nosplash -r MyMatlabScript(" + arg1 + " " + arg2 + ");";
	system(command.c_str());
}
'matlab' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . .

Thanks for trying this. Matlab is a program and MyMatlabScript.m is function which can take two arguments. I do not think there is a problem with Matlab, but how can i include "(" in my system call. I am working on Linux terminal.

This article has been dead for over six months. Start a new discussion instead.