Removing Characters from a File

前端 未结 1 1068
名媛妹妹
名媛妹妹 2021-01-23 06:08

How can arbitrary characters be removed (not replaced by something) in a file?

#include 

int main()
{
    std::fstream FileStream(\"MyFile.txt\",         


        
1条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-23 06:25

    You have two options:

    1. Read the entire file in the memory, then save it to the file excluding unwanted parts.
    2. Copy the source file to newly created file excluding unwanted parts, remove the source file, then rename second file.

    0 讨论(0)
提交回复
热议问题