Can I use str.append to create a new string with no vowels in C++?

  append, c++, iterator, string

I am trying to practice C++. I am an amateur. The assignment from codewars.com is to create a program that will take a troll’s comments and transform it into a statement with no vowels.

My idea is to get the comment, return all the characters that are not vowels and put it in a new string array using an iterator.

The error:
no matching function for call to std::__cxx11::basic_string::append(char&)’

My first question is why is the append() not working?
My second question is, without providing any solution, which concept of C++ can help me improve this code? I was thinking perhaps using a container of some sort and popping out a vowel?

Thanks.

int main()
{
string troll;
string disemvoweled;

getline(cin,troll);
int length= (int) troll.length();

string::iterator it;

for (it = troll.begin();it!=troll.end();it++) {
    if (*it!='a' || *it!='e' || *it!='i' || *it!='o' || *it!='u' || *it!='A' || *it!='E' ||*it!='I' || *it!='O' || *it!='U'){
    disemvoweled.append(*it);
    }
}
cout << disemvoweled;

    return 0;

Source: Windows Questions C++

LEAVE A COMMENT