Hi all
I am trying to remove consecutive blank space by single blank space but getting error by this small line-
ch='';
This is what I have done till now-

#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())
    {
        if(isspace(ch))
               count++;

          if(count >= 2)
          {
               ch='';
               count = 0;
          }          
          else
          {
              out_stream <<ch;
          }
          out_stream << ch;
    }
}

`Error is - Character constant must be one or two charcters long`

I am learning C++ in Turbo C++ as per our syllabus requirement.

Thank you in advance

There is no such thing as char='' (no spaces between the two ticks '). Put a space between the two ticks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.