多次复制文件

时间:2019-05-24 17:39:36

标签: c++

我的任务是使用操作员将in.txt文件复制到out1.txt,out2.txt等文件中

我所做的是

#include <fstream>

using namespace std;

ifstream& operator>> (ifstream &in,ofstream &out) {
    char c;
    while (in.get (c)) out.put (c);
    return in;
}
int main () {
    ifstream fa ("in.txt");
    ofstream fb ("out1.txt");
    ofstream fc ("out2.txt");
    ofstream fd ("out3.txt");
    fa>>fb>>fc>>fd;
    fa.close();
    fb.close();
    fc.close();
    fd.close();
}

文件out1,out2,out3必须与in相同,但实际上out2和out3为空。希望有人能帮忙,谢谢

0 个答案:

没有答案
相关问题