Assume the following:
string s("!Hello!'");
My goal is to get in the variable s only the string "Hello", IOW I want to remove the exclamation points.
I tried the following:
std::remove ( s.begin(), s.end(), '!' );
When I exit the resulting string s, I get:
Helloo!
"!" characters were deleted, but the end of the line was not moved.
I read that I need to return an iterator from the return value of std :: remove, but I'm new to C ++ and not succeeding in it.
I expect something like char :: iterator to be valid, but it seems not ... so
char::iterator new_end;
new_end = std::remove ( s.begin(), s.end(), '!' );
cout << new_end ;
doesn't do that.
Any help / pointers would be appreciated!
source
share