Write a C++ Program demonstrating files
#include
#include
#include
#include
#include
void main()
{
fstream fin,fout;
char ch;
int flag = 1;
clrscr();
fin.open("data.txt",ios :: out | ios :: in);
fout.open("data1.txt",ios :: out | ios :: in);
fin.seekg(0);
if(fin==NULL)
cout<<"Unable to open file";
while(fin)
{
fin.get(ch);
if(ch == ' ')
{
flag = 0;
}
else
{
if(flag == 0)
{
fout.put(' ');
cout<< ' ';
flag = 1;
}
fout.put(ch);
cout<
}
}
}