流对象的使用2
2016-02-22 21:20
351 查看
#include <iostream> #include <fstream> #include <string> #include <vector> using namespace std; void process(string s) { cout << s << endl; } int main() { vector<string> files; files.push_back("one.txt"); files.push_back("two.txt"); files.push_back("three.txt"); string s; vector<string>::const_iterator it = files.begin(); while (it != files.end()) { ifstream input(it->c_str()); if (!input) { cerr << "error: can not open file? " << *it << endl; input.clear(); ++it; continue; } while (input >> s) process(s); input.close(); input.clear(); ++it; } return 0; }
相关文章推荐
- 多个Mapper和Reducer的Job
- [转]Material Design Library 23.1.0的新变化与代码实战
- Unity3D FlappyBird
- Sublime Text非官方文档(搜索与替换之单文件)
- Zephyr微内核初探
- C++面向对象编程<七>:堆栈、类模板、函数模板及其他补充
- 算法导论22.3-13
- 删除windows回收站右键菜单中的“找回清空文件”
- android 解码出来的视频frame数据,是如何一步步的传递到显示端的(使用hwc composer online 合成)
- 全双工的WebSocket
- SpringMVC源码解读 - HandlerMapping - AbstractDetectingUrlHandlerMapping系列初始化
- [设计模式]工厂方法模式
- 从MVC框架看MVC架构的设计
- STL的移动算法
- 你读到了什么:谈谈阅读的空与实
- demo02TextView
- nmcli 配置网络
- brother[扫描线]
- 用php的定界符EOT需要留个心眼
- springMVC-interceptors