void trim(string& astring, const char t){
string::iterator it;
for (it=astring.begin() ; it < astring.end(); it++){
if(*it==t){
astring.erase(it);
};
}
}
string::iterator it;
for (it=astring.begin() ; it < astring.end(); it++){
if(*it==t){
astring.erase(it);
};
}
}
usage example
trim (number, ' ');
I think it is quite clear.
No comments:
Post a Comment