根据空格分割C ++字符串

时间:2019-12-17 18:43:48

标签: c++

我有一种方法可以根据定界符分割c ++字符串并存储到向量中

void tokenize(string const &str, const char delim, vector<std::string> &out) {
    size_t start;
    size_t end = 0;

    while ((start = str.find_first_not_of(delim, end)) != std::string::npos){
        end = str.find(delim, start);
        out.push_back(str.substr(start, end - start));
    }
}

有没有办法使所有空白都可以使用,例如空白可以是''或'\ t'或任何其他空白。

是否可以将这种方法更改为像这样或您建议的其他任何方式?

0 个答案:

没有答案