linux下程序调试使用文件重定向
2016-04-01 12:17
645 查看
c++ primer 5th教给我的小技巧:
usinng the file redirection.
It can be tedious to repeatedly type these transactions as input to the program you are testing . Most OS support file redirection , which let us associate a named file with the standard input and the standard output , for example :
(the test is a program that can run under linux)
test.cpp
g++ -o test test.cpp
新建一个输入文件:nano input /nano为linux新建文件的一个命令,nano也是一个行编辑器/
在input文件中输入:
1 2 3 4 5
新建一个输出文件:nano output
运行程序:./test output
打开output看一下里面的内容:nano output
12345
OK.这里要注意的就是使用重定向的时候,输入文件外面的两个尖括号不能少。
usinng the file redirection.
It can be tedious to repeatedly type these transactions as input to the program you are testing . Most OS support file redirection , which let us associate a named file with the standard input and the standard output , for example :
(the test is a program that can run under linux)
test.cpp
#include <iostream> using namespace std; int main() { int a; while ( cin >> a) { cout << a; } return 0; }
g++ -o test test.cpp
新建一个输入文件:nano input /nano为linux新建文件的一个命令,nano也是一个行编辑器/
在input文件中输入:
1 2 3 4 5
新建一个输出文件:nano output
运行程序:./test output
打开output看一下里面的内容:nano output
12345
OK.这里要注意的就是使用重定向的时候,输入文件外面的两个尖括号不能少。
相关文章推荐
- Linux 自检和 SystemTap
- Python 七步捉虫法
- 路由器的配置与调试
- 对于技术人员的出现了运行时间错误,是否要进行调试的解决方法
- 讲解WordPress开发中一些常用的debug技巧
- JavaScript程序设计之JS调试
- 可以用来调试JavaScript错误的解决方案
- 如何调试异步加载页面里包含的js文件
- jQuery下的Ajax调试步骤
- 调试一段PHP程序时遇到的三个问题
- JavaScript高级程序设计 错误处理与调试学习笔记
- Javascript调试脚本的经验之谈第1/2页
- 在IE,Firefox,Safari,Chrome,Opera浏览器上调试javascript
- Android App调试内存泄露之Cursor篇
- Lua的编译、执行和调试技术介绍
- 10个调试和排错的小建议
- 调试PHP程序的多种方法介绍
- PHP调试函数和日志记录函数分享
- PHP调试的强悍利器之PHPDBG
- Visual Studio调试技巧汇总