// 分割字符串
void split(const string &line, const string &sep, vector<string> &res){
size_t start = 0;
size_t index = line.find_first_of(sep, start);
while( index != string::npos ){
if( index - start > 0 )
res.push_back( line.substr(start, index - start) );
start = index + 1;
index = line.find_first_of(sep, start);
}
if( index - start > 0 )
res.push_back( line.substr(start, index - start) );
}
C++ 实现string的split
最新推荐文章于 2023-01-18 09:08:26 发布