且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

最快的方式来创建大型文件在C + +?

更新时间:2023-11-23 23:35:22

使用旧式文件io



fopen

fseek 转换为所需的文件大小 - 1. 一个字节

fclose 文件

Create a flat text file in c++ around 50 - 100 MB with the content 'Added first line' should be inserted in to the file for 4 million times

using old style file io

fopen the file for write.

fseek to the desired file size - 1.

fwrite a single byte

fclose the file