For exercise 8.6

 // ConsoleApplication10.cpp : 定义控制台应用程序的入口点。
// #include "stdafx.h"
#include <iostream>
#include <fstream>
#include <sstream> using namespace std; void print(istream &in)
{
string str;
while (in >> str)
{
cout << str << endl;
}
} int main()
{
ifstream in("d://hello.txt");
print(in);
in.clear();
in.close();
return ;
}

For Exercise 8.7

 #include "stdafx.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector> using namespace std; int main()
{
vector<string> vect;
vect.push_back("d://hello0.txt");
vect.push_back("d://hello.txt");
vect.push_back("d://hello1.txt");
vect.push_back("d://hello2.txt");
for (vector<string>::iterator begin = vect.begin(); begin != vect.end(); ++begin)
{
ifstream in;
in.open(begin->c_str());
if (!in)
{
cout << begin->c_str() << " does not exist in the system!!!" << endl; continue;
}
cout << "opening the file with name is: " << begin->c_str() << endl;
string str;
while (in >> str)
{
cout << str << endl;
}
in.clear();
in.close();
}
return ;
}

最新文章

  1. sublime 添加代码片段(snippets)
  2. hdu Is It A Tree?
  3. Java中sleep()和wait()的区别
  4. XCODE中的蓝色文件夹与黄色文件夹
  5. CocoaPods的安装[转载]
  6. windows下AppServ安装php的memcached扩展
  7. C#的委托 Action&lt;&gt;和Func&lt;&gt;
  8. td中使用overflow:hidden; 无效解决方案
  9. lc面试准备:Remove Duplicates from Sorted List II
  10. ExtJs5_继承自定义一个控件
  11. Webpack 2 视频教程 020 - Webpack 2 中的 HMR ( Hot Module Replacement )
  12. ES6的generator函数
  13. Docker学习笔记 - Docker的守护进程
  14. 解决python编码问题
  15. RESTful api风格介绍
  16. JIRA和Confluence更改JVM内存大小解决访问打开缓慢问题
  17. SQL Server清空日志以及查看日志大小语句
  18. sql 中常见的控制流语句
  19. table添加行
  20. CentOS工作内容(七)禁用IPV6

热门文章

  1. LeetCode Database题解
  2. HTTPS=HTTP + SSL / TLS
  3. Golomb及指数哥伦布编码原理介绍及实现
  4. LoadRunner相关架构图
  5. Spring之循环依赖
  6. I/O模型浅析
  7. PickerController 添加照片---iOS
  8. Python开发项目:大型模拟战争游戏(外星人入侵)
  9. DOM解析,取得XML文件里面的信息
  10. Java 程序测试_判断语句