Erase characters in std::string
All i'm trying to do is erase the first occurance of a character in a std::string.
str::erase(iterator) takes an iterator as an argument, but std::find() returns size_type.
This is the best i can come up with.
There's has got to be an easier way right?
Code:
int main(int argc, char *argv[])
{
string str = "seller";
char c = 'l';
string::iterator pos;
pos = str.begin();
//seek first occurence
while(pos != str.end() && *pos !=
c)
pos++;
//erase first occurence
str.erase(pos);
cout << str << endl;
return 0;
}