Answer to Question #176406 in C++ for Kajal Kurre

Question #176406

Copy the contents of one text file to another file, after removing all whitespaces.


1
Expert's answer
2021-03-30T02:31:10-0400


#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();
	}
}

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