第十六周阅读项目-3
2016-06-10 18:13
134 查看
/*copyright(c)2016.烟台大学计算机学院 * All rights reserved, * 文件名称:text.Cpp * 作者:刘涛 * 完成日期:2016年6月10日 * 版本号:vc++6.0 * 问题描述:阅读程序 */ #include <iostream> #include <fstream> #include<cstring> using namespace std; int main() { ifstream readFile; ofstream writeFile; char ch[100]; readFile.open("a.txt",ios::in); writeFile.open("b.txt",ios::out); while(!readFile.eof()) { readFile.getline(ch,100,'\n'); writeFile.write(ch,strlen(ch)); writeFile.write("\n",1); } readFile.close(); writeFile.close(); cout << "Finish!" << endl; return 0; }
运行结果:
因为a.txt中没有任何元素,所以循环条件一下子就循环出去了,write也没有读入到输出流中。
相关文章推荐
- MySQL系列:(2)MySQL基础
- Oracle 创建数据库及导入数据
- Andorid linux常用的指令
- Java的构造器和隐式参数和显式参数
- 文件提取小工具
- Git多个ssh key配置
- PHP学习笔记之二
- C++ 副本构造器
- Android TextView setText内嵌html标签
- html/css排版一些简单的数学公式
- 转发 源框架GPUImag
- spoj COT && COT2
- 自己编写的 matlab 线性索引转换下标 函数
- Linux移植的一般过程
- 大型网站架构系列:缓存在分布式系统中的应用(二)
- Hibernate hql查询
- Servlet的学习(二)-ServletConfig对象和ServletContext对象
- Android自启动管理
- 大型网站架构系列:缓存在分布式系统中的应用(一)
- mysql删除表