最简单的读文本文件

#include <iostream>
#include <fstream>
using namespace std;

int main()
{
		ifstream fin("d:\\data\\english_story.txt");
	if(fin.good())
	{
		cout<<"打开文件成功,以下是文件内容"<<endl;
		char ch;
		while (!fin.eof())//未到文件尾时循环
		{
			ch=fin.get();
			cout<<ch;
		}
	}
	else cout<<"打开文件错误"<<endl;
	fin.close();
	return 0;
}


posted @ 2010-10-27 00:59  瓜蛋  阅读(195)  评论(0编辑  收藏  举报