I need to execute a perl script from my c++ code. This is done with system().
Now I need to pass the second argument from my code:
int main(int argc, char * argv[])
into my system() like this:
char *toCall="perl test.pl "+argv[1];
system(toCall);
Now it brings the error: “invalid operands of types ‘const char [14]’ and ‘char**’ to binary ‘operator+’”
What am I doing wrong?
Use
std::string, likeYou cannot add two raw pointers.
But
std::stringprovides an overload of the+operator.