c++系统命令
c++ system command
我已经编写了一个示例c++程序。。。在这里,我使用system命令调用带有参数的python程序。。。
system("python /home/rpms/a3/dsp/noise_rem_python.py /home/rpms/a3/dsp/files/p1f%d.txt",tid);
/home/rpms/a3/dsp/noise_rem_python.py is a program name
/home/rpms/a3/dsp/files/p1f%d.txt
是该程序的一个参数。
但我得到的错误是:
"/usr/include/stdlib.h:在函数'void*writefile(void*)'中:/usr/include/stdlib.h:712:错误:函数"int system(const char*)"的参数太多writefile.cpp:29:错误:此时在文件""中
您也可以这样做:
char command[200]; // 200 is just an example value that can hold the whole string
sprintf(command, "python /home/rpms/a3/dsp/noise_rem_python.py /home/rpms/a3/dsp/files/p1f%d.txt", tid);
system(command);
如果你想用同样的风格来做。
这样说:
#include <string>
system(("python /home/rpms/a3/dsp/noise_rem_python.py /home/rpms/a3/dsp/files/p1f" + std::to_string(tid) + ".txt").c_str());
查看传递给函数的参数的末尾
tid);
如果您正在尝试格式化字符串?在把它用作论据之前先做一下。
相关文章:
- 提供变量作为 MATLAB 系统命令的输入参数,以便C++可执行文件
- 将系统命令打印到文本文件 C++
- 使用系统命令时发送输入不起作用
- 有没有一种简单的方法可以将系统命令的输出转换为字符串
- 如何将 c ++ 变量的值传递给 hadoop HDFS 的 bash 系统命令?
- 来自C 应用程序的运行系统命令与Commandline不同
- CPP中的管道内部(AWK)系统命令
- C++:如何运行一个系统命令N次(异步)并返回N次执行时间
- 使用 C++ 更改注册表值?(系统命令失败)
- 使用系统命令调用可执行文件
- c++系统命令
- 如何在C++中通过将每个命令分配给线程来同时执行linux系统命令
- C++函数系统(命令)的输出在Linux终端中不显示颜色
- 使用Windows技术检测复制,粘贴,打印系统命令
- 使用系统命令从 Windows 下的 C 程序内部更改目录
- 有没有办法以给定的优先级执行系统命令
- 在Qt创建器运行系统命令中
- 如何使用system()在c中执行2个成功的系统命令,例如连接到ftp并使用程序登录
- C++重置系统命令
- 系统命令在C++中不起作用