Answer to Question #180694 in C++ for Ravi kumar pandey

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.


1
Expert's answer
2021-04-12T12:20:35-0400
#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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS