#include<iostream>
#include<string>
#include<vector>
using namespace std;
vector< string > string2word(string s)
{
int start = 0;
int count = 0;
vector< string > eachline;
for(int j=0; j<s.size(); j++) //把s分成word
{
string ss;
if(s[j] == ' '|| j==(s.size()-1))
{
if(j==s.size()-1)
count++;
string ss(s.substr(start,count));
eachline.push_back(ss);
start = j+1;
count = 0;
}else{
count ++;
}
}
return eachline;
}
C++ string转化为以空格符隔开的word向量
最新推荐文章于 2022-01-02 17:46:53 发布