cpp
int main()
{
string s = "How are you?";
string mark = " ";
string tmp;
int cur = 0, first = 0;
//找到第一个标记
while ((cur = s.find_first_of(mark, cur)) != string::npos)
{
//获取第一个标记前的子串
tmp = s.substr(first, cur - first);
cout << tmp << " ";
//下一段有效字符
first = ++cur;
}
//最后一段有效字符
if (first != s.size())
{
tmp = s.substr(first, cur - first);
cout << tmp << " ";
}
cout << endl;
return 0;
}