#include <iostream>
#include <string>
#include <vector>
using namespace std;
//切割函数
vector<string> split(string src, string splitCharactor)
{
vector<string> coll;
int begin = 0, end = 0;
cout << "src.length()= " << src.length() << endl;
while (begin < src.length())
{
end = src.find(splitCharactor.c_str(), begin);
if (end == -1)
end = src.length();
coll.push_back(src.substr(begin, end - begin));
begin = end + splitCharactor.length();
}
return coll;
}
int main()
{
string s1 = "abc def hij ttt";
vector<string> v = split(s1, " def");//切割
unique_copy(v.begin(), v.end(), ostream_iterator<string>(cout, "\n"));//输出
return 0;
}