Write a function called clean that takes a C++ string as input and removes any characters in the string that are not letters except for space blanks. code example
Example: Write a function called clean that takes a C++ string as input and removes any characters in the string that are not letters except for space blanks.
void clean ( string & str)
{
for ( int i = 0; i < str.length(); i++ )
{
if (str[i] != ' ' && (str[i] < 'A' || (str[i] > 'Z' && str[i] < 'a') || str[i] > 'z'))
{
str.replace(i, 1, "");
i--;
}
}
}