OK Thank you every one for considering my problem. I got the solution from
http://cbsecsnip.in under question No. 15
Write a program that reads a text file and creates another file that is identical expect that every sequence of consecutive blank space is replaced by a single space.
here is the final code
#include <fstream.h>
#include <iostream.h>
#include <ctype.h>
#include <conio.h>
void main()
{
char ch;
int count=0;
ifstream in_stream;
ofstream out_stream;
clrscr();
in_stream.open("A.txt");
out_stream.open("B.txt");
while (!in_stream.eof())
{
ch = (char)in_stream.get( );
if(isspace(ch))
count++;
if(count >= 2)
{
ch=' ';
count = 0;
}
else
{
out_stream <<ch;
}
}
}</conio.h></ctype.h></iostream.h></fstream.h>
Working perfect