python - How to embed commandline arguments in a execution command? -
i need pass commandline arguments of c++ code commandline arguments of python script.
my code looks like:
int main(int argc,char * argv[]) { file *in; char buff[512]; cout<<argv[1]; string str = "python comparescript.py "+argv[1]+" "+argv[2]+" "+argv[3]; if(!(in = popen(str, "r"))){ cout<<"image comparison made successful"; } cout<<"image comparison made successful"; it shows eror :
error: invalid operands of types 'const char [25]' , 'char*' binary 'operator+'
how append commandline arguments python execution command?
to able concatenate strings using + operator, @ least 1 of them needs std::string object.
the simplest solution? do
string str = string("python comparescript.py ")+argv[1]+" "+argv[2]+" "+argv[3];
Comments
Post a Comment