
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文件的最快方法是什么?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)