I'm trying to remove all whitespace and punctuation marks from a string. But my function only returns the first word of the whole sentence. Where is the problem? Here is my code:
string Convert(string line)
{
string phrase = "";
for (int i = 0; i < line.size(); ++i)
{
if (line[i] >= 'a' && line[i] <= 'z')
phrase += line[i];
}
return phrase;
}
int main()
{
string input;
cin >> input;
input = Convert(input);
cout << input;
}