Question #106

How to copy from an existing file to another one in C++?

Expert's answer

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

int main()
{
string a;

fstream inputFile("C:\\TEMP\\samp1.txt");
fstream outputFile;
outputFile.open("C:\\TEMP\\samp2.txt");

while (!inputFile.eof()) {
inputFile >> a;
outputFile << a << endl;

}
outputFile.close();
}

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