字符串切分

bool split_str(const string& s, const string& delim, vector<string>* ret)
{
    int last = 0;
    int index = s.find_first_of(delim, last);
    int length = s.size();
    int end = string::npos;
    while (index != end){
        ret->push_back(s.substr(last, index - last));
        last = index + 1;
        index = s.find_first_of(delim, last);
    }
    if (length > last){
        ret->push_back(s.substr(last, index - last));
    }
    return true;
}
原文地址:https://www.cnblogs.com/xiongji/p/6909054.html