在CC++中创建填充零的1GB文件的最快方法是什么?

在CC++中创建填充零的1GB文件的最快方法是什么?,第1张

概述我需要在 Windows *** 作系统中创建一个填充零的巨大二进制文件.它的大小是给定的.在C/C++中最有效的方法是什么? 尝试调用truncate(2): truncate("/my/file", my_size); 欲获得更多信息, man 2 truncate The truncate() and ftruncate() functions cause the regular file name 我需要在 Windows *** 作系统中创建一个填充零的巨大二进制文件.它的大小是给定的.在C/C++中最有效的方法是什么?解决方法 尝试调用truncate(2):
truncate("/my/file",my_size);

欲获得更多信息,

man 2 truncate

The truncate() and ftruncate() functions cause the regular file named by path or referenced by fd to be truncated to a size of precisely length bytes.

If the file prevIoUsly was larger than this size,the extra data is lost. If the file prevIoUsly was shorter,it is extended,and the extended part reads as null bytes (‘\0’).

如果您正在寻找windows本机功能,请查看SetEndOfFile,它的功能大致相同.

总结

以上是内存溢出为你收集整理的在C/C++中创建填充零的1GB文件的最快方法是什么?全部内容,希望文章能够帮你解决在C/C++中创建填充零的1GB文件的最快方法是什么?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1236633.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-06
下一篇2022-06-06

发表评论

登录后才能评论

评论列表(0条)

    保存