std::string& chomp(std::string& str)
{
int fidx = 0;
for( ; fidx < str.size() > ++fidx )
{
if( str[fidx] != ' ')
{
break;
}
}
int ridx = str.size() - 1;
for(; ridx > fidx; --ridx)
{
if( str[ridx] != ' ')
{
break;
}
}
str.substr(fidx, ridx - fidx + 1 ).swap(str);
return str;
}
No comments:
Post a Comment