C ++从底部到顶部读取文件 [英] C++ Read file from bottom to top

查看:176
本文介绍了C ++从底部到顶部读取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常大的文件,我需要解析,所以一次读入内存是不理想的。文件的结构,如果我可以从eof开始,一直到开始,这将是很多,更容易。有没有人有一个好的技巧这样做?我使用Visual Studio 2008和C ++。感谢

I have a very large file I need to parse, so reading it into memory all at once is non-ideal. The way the file is structured, it would be much, much easier if I could start at eof and go up to the beginning. Does anyone have a good trick for doing this? I'm using Visual Studio 2008 and C++. Thanks

推荐答案

如果您的操作系统支持它,请考虑使用内存映射文件。然后,您可以将文件内容视为一个非常大的字节数组,操作系统根据需要管理将数据导入内存(并释放它)。

If your operating system supports it, consider using a memory mapped file. You can then treat the file contents as a very large array of bytes, with the operating system managing bringing the data into memory (and releasing it) as necessary.

这篇关于C ++从底部到顶部读取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆