Copy the contents of one text file to another file, after removing all whitespaces.
#include <bits/stdc++.h>
using namespace std;
main(void)
{
fstream infile,outfile;
char x;
string Name1 = "H:\\Input.txt";
string Name2 = "H:\\Output.txt";
infile.open(Name1.c_str());
outfile.open(Name2.c_str());
if (!infile)
{
cout << "Unable to open file: "<<Name1;
exit(1); // terminate with error
}
else
{
while(infile >> x)
{
cout<<x;
outfile<<x;
}
infile.close();
outfile.close();
}
}
Comments
Leave a comment