#include <vector>
#include <string>
#include <iostream>
using namespace std;
const vector<string> explode(const string& s, const char& c)
{
string buff{""};
vector<string> v;
for(auto n:s)
{
if(n != c) buff+=n; else
if(n == c && buff != "") { v.push_back(buff); buff = ""; }
}
if(buff != "") v.push_back(buff);
return v;
}
int main()
{
string str{"您好,欢迎开始,我们开始测试,了"};
vector<string> v{explode(str, ',')};
for(auto n:v)
{
cout << n << endl;
}
return 0;
}
C++拆分字符串
猜你喜欢
转载自blog.csdn.net/jadeshu/article/details/103776189
今日推荐
周排行