How to copy text file in C or C++?

后端 未结 6 679
走了就别回头了
走了就别回头了 2020-12-11 06:00

When trying to copy a text file A to another file B, there may have several methods: 1) byte by byte 2) word by word 3) line by line

which one is more efficient?

6条回答
  •  被撕碎了的回忆
    2020-12-11 06:38

    Just "buffer by buffer", copy files in binary mode and read/write X bytes long parts. I think that fastest solution is to just use copy function of C language itself or system call.

    Largest buffer will provide you less HDD find for data operations (faster copying) but more RAM usage.

提交回复
热议问题