Question #180694

John has some data in his laptop saved in two different files, but now he wants to add the data in one file to another file. Write a program to complete John's task.


Expert's answer

#include <iostream>
#include <fstream>
using namespace std;

int main() {
    ifstream in("one.txt");
    ofstream out("another.txt", ios_base::out | ios_base::app);

    for (string str; getline(in, str); ) {
        out << "\n" << str << "\n";
    }
    
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS