0

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

2
Contributors
1
Reply
17
Views
3 Years
Discussion Span
Last Post by Ancient Dragon
0

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

Edited by Ancient Dragon

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.