如何使用C/C ++编写/创建大于2GB的文件 [英] How can I write/create a file larger than 2GB by using C/C++

查看:152
本文介绍了如何使用C/C ++编写/创建大于2GB的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用write()函数将大块内存写入文件(大于2GB),但从未成功.有人可以告诉我该怎么做吗?

I tried to use write() function to write a large piece of memory into a file (more than 2GB) but never succeed. Can somebody be nice and tell me what to do?

推荐答案

假设Linux:)

http://www.suse.de/~aj/linux_lfs.html

1/将_FILE_OFFSET_BITS定义为64 2/定义_LARGEFILE_SOURCE和_LARGEFILE_SOURCE64 4/将O_LARGEFILE标志与open一起使用可对大文件进行操作

1/ define _FILE_OFFSET_BITS to 64 2/ define _LARGEFILE_SOURCE and _LARGEFILE_SOURCE64 4/ Use the O_LARGEFILE flag with open to operate on large file

这里还有一些信息: http://www.gnu.org /software/libc/manual/html_node/Opening-Streams.html#index-fopen64-931

Also some information there: http://www.gnu.org/software/libc/manual/html_node/Opening-Streams.html#index-fopen64-931

这几天,您系统上的文件系统将立即支持大文件.

These days the file systems you have on your system will support large file out of the box.

这篇关于如何使用C/C ++编写/创建大于2GB的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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