Using argument char argv[] in system()
arguments, c++, command-line-arguments
Solution
Use `std::string`, like
std::string const command = std::string( "perl test.pl " ) + argv[1];
system( command.c_str() );
You cannot add two raw pointers.
But `std::string` provides an overload of the `+` operator.
Problem
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?