I need to pass the commandline arguments of my C++ code as the commandline arguments of my 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 an eror like :
error: invalid operands of types 'const char [25]' and 'char*' to binary 'operator+'
How to append my commandline arguments with the python execution command?
To be able to concatenate strings using the
+
operator, at least one of them needs to be astd::string
object.The simplest solution? Just do