jav*_*ure 2 c++ arguments command-line-arguments
我需要从我的c ++代码中执行perl脚本.这是通过system()完成的.
现在我需要从我的代码中传递第二个参数:
int main(int argc, char * argv[])
Run Code Online (Sandbox Code Playgroud)
进入我的系统()像这样:
char *toCall="perl test.pl "+argv[1];
system(toCall);
Run Code Online (Sandbox Code Playgroud)
现在它带来了错误:"类型'const char [14]'和'char**'的无效操作数到二进制'运算符+'"
我究竟做错了什么?
使用std::string,像
std::string const command = std::string( "perl test.pl " ) + argv[1];
system( command.c_str() );
Run Code Online (Sandbox Code Playgroud)
你不能添加两个原始指针.
但是std::string提供了+操作员的过载.
| 归档时间: |
|
| 查看次数: |
4269 次 |
| 最近记录: |