Wednesday, November 9, 2016

File Copying :)

Tags

Program To Copy The Contents of One File To Another ,so that other file is Identical Except Every Consecutive blank Space is replaced by Single Space.

#include<iostream>
#include<fstream>
using namespace std;
main()
{
ifstream fin("text.txt");
ofstream fout("text2.txt");
char c=fin.get(),d;
while(fin)
{
fout.put(c);
d=fin.get();
if(c==' '&&d==' ')
{
d=fin.get();
}
c=d;
}
}

File  Output:
Text.txt


Text2.txt