linux 下c/c++ 使用shell命令并加入参数、保存结果
2016-07-27 20:02
429 查看
linux 下c/c++中使用shell命令的格式为: system("ls -l");
将命令得到结果结果保存的一种方式是: system("ls -l >result.txt");
若想使用参数作为传入命令中,使用string:
string resultTXT = "result.txt";
string command = "ls -l >" + resultTXT ;
system(command.c_str());
将命令得到结果结果保存的一种方式是: system("ls -l >result.txt");
若想使用参数作为传入命令中,使用string:
string resultTXT = "result.txt";
string command = "ls -l >" + resultTXT ;
system(command.c_str());
相关文章推荐
- Linux socket 初步
- android wifi 无线调试
- Linux Kernel 4.0 RC5 发布!
- linux lsof详解
- linux 文件权限
- Linux 执行数学运算
- 10 篇对初学者和专家都有用的 Linux 命令教程
- Linux 与 Windows 对UNICODE 的处理方式
- Ubuntu12.04下QQ完美走起啊!走起啊!有木有啊!
- 解決Linux下Android开发真机调试设备不被识别问题
- 运维入门
- 运维提升
- Linux 自检和 SystemTap
- 动态清空 nohup 输出文件
- install scrapy with pip and easy_install
- Ubuntu Linux使用体验
- c语言实现hashmap(转载)