I have read some threads on this warning and I understand what the warning is and there have been suggestion on how to get around the warning, but how do you code it correctly not to get the error?
In my class we are studing namespace,typedef, string functions the assignment is to accept an input string and strip out the vowels. I'm getting the error and I'm not sure how to actually fix the code instead of getting around the warning. Thanks for any help
#include <iostream>
#include <string>
using namespace std;
string removeVowels(string userstr);
bool IsVowel(char chr);
int main ()
{
string userstr;
cout<< "Please provide some text:" << endl;
cin>> userstr;
cout<<"The text you entered is: "<< userstr <<endl;
cout<< "Your text with vowels removed is:" << removeVowels(userstr) << endl;
return 0;
}
///method for removing each vowel in the string
string removeVowels(string userstr)
{
string::size_type len = userstr.length();
string finalString;
// string::size_type len;
string::size_type counter;
//loop through each character in the
//provided string
for(int i = 0; i < userstr.size(); i++)
// for ( string::size_type i = 0; i < s.length(); i++ ) {
{
if(!(isVowel(userstr[0]))
{
//it's not a vowel so we can
//add it to our return value
finalString += userstr[i];
}
}
return finalString;
}
//method to check if the current character is a vowel
bool IsVowel(char chr)
{
switch (ch)
{
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
case 'Y':
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
case 'y':