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;
}