您的位置:首页 > 其它

第十六周阅读项目-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也没有读入到输出流中。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: