截取函数实现
void GetSubStrings(const string& totalStr, const string& delim, vector<string>& res)
{
res.clear();
if (totalStr == "")
{
return ;
}
char *strArray = new char[totalStr.length() + 1];
strcpy(strArray, totalStr.c_str());
char *delimArray = new char[delim.length() + 1];
strcpy(delimArray, delim.c_str());
char* curChar = strtok(strArray, delimArray);
while (curChar)
{
string curStr = curChar;
res.push_back(curStr);
curChar = strtok(NULL, delimArray);
}
}
标签:分割,curChar,delimArray,分隔符,delim,char,totalStr,字符串,string From: https://www.cnblogs.com/xiaoxiaoshi/p/17483587.html