The purpose of my program is to remove all the vowels in a string.
std::string disemvowel(std::string str)
{
for (unsigned int i = 0; i < str.length(); ++i)
{
switch(str[i])
{
case 'A':
case 'a':
case 'E':
case 'e':
case 'I':
case 'i':
case 'O':
case 'o':
case 'u':
case 'U': str.erase(str.begin() + i);
break;
default:
break;
}
}
return str;
}
Inputting a string: aaAAaiieEeOoU,,,.,132@
The characters that are accessed and deleted are: aAaiEOU,,.,132@
Result String: aAieeo,,,.,132@
The program seems to just never access the vowels above.
I don't see any issue with how I'm approaching this. I should be accessing every character in the string until the end of its length, no?