#last word of string is not processed
12 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.
You can extract whole words from a string far easier using istringstream
set<string> gatherTokens(const string& text) {
set<string> tokens;
string token;
istringstream str(text);
while (str >> token)
{
tokens.insert(token);
}
}
thank you so much, is there any way I could simplify this 2 while loop?
while(ispunct(s[end]) != 0)
{
s = s.substr(begining, end);
end--;
}
while(ispunct(s[begining]) != 0)
{
begining++;
}```
I tried taking out ```s = s.substr(begining, end);```
but it wouldn't work
while (ispunct(s.back())
{
s.pop_back();
}
Thank you!
!solved
Thank you and let us know if you have any more questions!
[SOLVED] last word of string is not processed
I am not sure about removing punctuation from the front though.
There doesn't appear to be a string::pop_front() method.
Perhaps:
while (ispunct(s.front())
{
s.erase(s.begin());
}
@safe holly
This question thread is being automatically marked as solved.