i have made a program on text file to remove extra blank spaces in a file but it is not working correctly. when i run the program just "enter text" appears and after entering the text the screen just remains as it was. Nothing else appears. I cant find where the problem lies.
char a[150];
char ch;
int count=0;
cout<<"Enter text"<<endl;
gets(a);
ofstream file("EXAMPLE.txt");
for(int i=0; a[i]!='\0'; i++)
{
file.put(a[i]);
}
file.close();
ifstream fin("EXAMPLE.txt");
ofstream fout("NEW.txt");
while(fin)
{
ch=fin.get();
while(ch==' ')
{
if(count==0)
fout.put(ch);
ch=fin.get();
count++;
}
fout.put(ch);
count=0;
}
fin.close();
fout.close();
ifstream fil("NEW.txt");
while(fil)
{
ch=fil.get();
cout<<ch;
}
thanx in advance...