记录学习过程中的点点滴滴
std::string的split函数的自定义实现
std::string中未定义split函数,网上找到一种方法实现,分享之
//自定义实现split函数
void split(std::string& s, std::string& delim,std::vector< std::string >* ret)
{
size_t last = 0;
size_t index=s.find_first_of(delim,last);
while (index!=std::string::npos)
{
string tt = s.substr(last,index-last);
tt.
ret->push_back();
last=index+1;
index=s.find_first_of(delim,last);
}
if (index-last>0)
{
ret->push_back(s.substr(last,index-last));
}
}
本文地址:http://www.yaronspace.cn/blog/index.php/archives/147
来自yaronspace.cn 本文链接:http://yaronspace.cn/blog/archives/147您可能对下面文章也感兴趣:
这篇文章由admin于2009 年 11 月 14 日 22:24发表在编程语言与算法设计。你可以订阅RSS 2.0 也可以发表评论或引用到你的网站。 |