第16周程序阅读(3)
2016-06-19 14:16
253 查看
*Copyright(c) 2016.烟台大学计算机与控制工程学院 *ALL rights reserved. *文件名称:第16周程序阅读(3) *作者:于子娴 *完成日期:2016年6月19日 *问题描述:说出程序的功能 文件操作(自建a.txt) */ #include <iostream> #include <fstream> #include<cstring> using namespace std; int main() { ifstream readFile; ofstream writeFile; char ch[100]={"Hello World!"}; cout<<ch<<endl; 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); } cout<<ch<<endl; readFile.close(); writeFile.close(); cout << "Finish!" << endl; return 0; }
运行结果:
相关文章推荐
- 深入学习Activity 之intent的匹配规则
- POJ 2420 A Star not a Tree? (模拟退火)
- ACM:蓝桥杯:小明的存钱计划
- Applet再学习
- 导入sql时报日期类型错误
- 【剑指offer】打印1到最大的n位数
- 《一步一步嵌入式操作系统》笔记2-环境搭建
- c++类及其基础规则详解
- [Set 单调] BZOJ 2926 [Poi1999]空立方体问题
- 4-3使用mailto在网页中链接Email地址
- 测验的答案
- iOS9新特性
- thymeleaf 模板引擎
- struts2标签引用
- [KD-TREE 堆] BZOJ 2626 JZPFAR
- C++ 多态 polymorphic 编译时期多态
- Bat命令学习
- JS数组
- 设计模式 - - - 从单例模式谈起
- windows 语音:根据文字说语音