Concatenate two huge files in C++

后端 未结 4 1261
感动是毒
感动是毒 2021-02-06 01:55

I have two std::ofstream text files of a hundred plus megs each and I want to concatenate them. Using fstreams to store the data to create a single file usually ends up with an

4条回答
  •  [愿得一人]
    2021-02-06 02:08

    Is there any way of merging them faster than O(n)?

    That would mean you would process the data without passing through it even once. You cannot interpret it for merging without reading it at least once (short answer: no).

    For reading the data, you should consider un-buffered reads (look at std::fstream::read).

提交回复
热议问题