您当前的位置: 首页 >  c++

C++文件读写——字符串分割

发布时间:2021-01-06 11:13:11 ,浏览量:0

文章目录
    • 字符串分割
字符串分割
void String_Split(std::string s, std::string delim, std::vector&ans) {
        std::string::size_type pos_1, pos_2 = 0;
        while (pos_2 != s.npos) {
            pos_1 = s.find_first_not_of(delim, pos_2);
            if (pos_1 == s.npos)break;
            pos_2 = s.find_first_of(delim, pos_1);
            ans.push_back(s.substr(pos_1, pos_2 - pos_1));
        }
    }
std::vectorsplit(std::string s, char token){
    std::stringstream iss(s);
    std::string word;
    std::vectorvs;
    while(getline(iss,word,token)){
        vs.push_back(std::atof(word.c_str()));
    }
    return vs;
}
bool getSubstr(std::string string_in, char char1, char char2, std::string &sub_get, std::string &a
关注
打赏
1688896170
查看更多评论

暂无认证

  • 0浏览

    0关注

    103100博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

2.8642s