读取大TXT文件的显示有关问题
读取大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++新手,编了一个读取文件的程序,但是这个程序只能读取存储量信息很小的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(); }