Detect new line c++ fstream

后端 未结 3 774
花落未央
花落未央 2021-01-18 05:18

How do I read a .txt copy the content to another .txt by using fstream to a similar content. The problem is, when in the file there is new line. How do I detect that while u

3条回答
  •  北荒
    北荒 (楼主)
    2021-01-18 05:40

    There's a much easier way to do the job:

    #include 
    
    int main() {
        std::ifstream inFile ("note.txt");
        std::ofstream outFile("note_new.txt");
    
        outFile << inFile.rdbuf();
    }
    

提交回复
热议问题