it's a program to remove extra spaces from a file.
please help need to get program working by tommorow........
Code:
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{
clrscr();
ifstream fin;
ofstream fout;
fstream f1;
char *line,ch,chh;
int s,f=0;
fout.open("xyz.txt");
cout<<"Enter a line:";
gets(line);
s=strlen(line);
fout.write(line,s);
fout.close();
fin.open("xyz.txt",ios::beg);
f1.open("file2.txt",ios::out,ios::in);
while(!fin.eof())
{
fin.get(ch);
if(ch==' ')
{
if(f==0)
{
f1.put(ch);
f=1;
}
}
else
{
f1.put(ch);
f=0;
}
}
fin.close();
cout<<"\nThe contents of the new file are:";
f1.seekg(0,ios::beg);
while(!f1.eof())
{
f1.get(chh);
cout<<chh;
}
f1.close();
getche();
}
hope to get a reply...
