首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

读取大TXT文件的显示有关问题

2012-02-29 
读取大TXT文件的显示问题大家好!我是个C++新手,编了一个读取文件的程序,但是这个程序只能读取存储量信息很

读取大TXT文件的显示问题
大家好!我是个C++新手,编了一个读取文件的程序,但是这个程序只能读取存储量信息很小的txt文件,当换成txt大文件(例如500K甚至1M)时,就只能显示整个文件的末尾一小部分。我不知道是什么问题,麻烦高手们给帮忙看一下吗?非常感谢

程序如下:
#include "stdafx.h"
#include <fstream.h>

void read(ifstream &T) 
{  
  char ch;
  while(!T.eof())
  {
  T.get(ch);
  cout << ch;
  }  
  cout << endl << "--------" << endl;
}

void main()
{
  ifstream T("D:\\1.txt");
  read(T);
  T.close();
}

感激!!!

[解决办法]

C/C++ code
#include <clx.h>#pragma hdrstop//#include "stdafx.h"#include <iostream>#include  <fstream.h >using namespace std;void read(ifstream &T)  {        char ch;     while(!T.eof())     {        T.get(ch);        cout  << ch;    }   cout  << endl  << "--------"  << endl;   getchar();}void main(){    ifstream T("D:\\1.txt");    read(T);     T.close(); } 

热点排行