分割字符串
void split(const string& strSrc, const string& strDelim, vector<string>& vecResult, int nMaxCount /*= 1000*/)
{
string str = strSrc;
size_t last = 0;
size_t index = str.find_first_of(strDelim, last);
while (index != std::string::npos && (int)vecResult.size() < nMaxCount)
{
vecResult.push_back(str.substr(last,index-last));
last = index+1;
index= str.find_first_of(strDelim,last);
}
vecResult.push_back(str.substr(last, str.length()-last));
}
引用:
split(str, "_", vecData);原字符str,(以'_'分割字符串),保存在vecData