C ++读取整个文本文件 [英] C++ Read Entire Text File
本文介绍了C ++读取整个文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用vc ++用此代码读取整个文本文件
i try to read the entire text file using vc++ with this code
ifstream file (filePath, ios::in|ios::binary|ios::ate);
if (file.is_open())
{
size = (long)file.tellg();
char *contents = new char [size];
file.seekg (0, ios::beg);
file.read (contents, size);
file.close();
isInCharString("eat",contents);
delete [] contents;
}
但它不是获取所有的文件,为什么和如何处理?
but it's not fetch all entire file ,why and how to handle this?
注意:文件大小为1.87 MB和39854行
Note : file size is 1.87 MB and 39854 line
推荐答案
感谢所有,我发现错误在哪里,
只是下面的代码读取整个文件,
问题是在VS观察者本身它只是显示一定量的数据,而不是全文件。
Thanks all, i found the error where, simply the code below reads the entire file , the problem was in VS watcher itself it was just display certain amount of data not the full text file.
这篇关于C ++读取整个文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文