Boost split string, which is very convenience
# Include <string> # include <iostream> # include <boost/format. HPP> # include <boost/tokenizer. HPP> # include <boost/algorithm/string. HPP> int _ tmain (INT argc, _ tchar * argv []) {STD: wcout. imbue (STD: locale ("CHS"); // the string to be split STD: wstring strtag = _ T ("I come from China"); STD :: vector <STD: wstring> vecsegtag; // boost: is_any_of indicates the splitting rule boost: Split (vecsegtag, strtag, boost: is_any_of (_ T (",, "); For (size_t I = 0; I <vecsegtag. size (); I ++) {STD: wcout <vecsegtag [I] <STD: Endl;} vecsegtag. clear (); STD: wstring strtag2 = _ T ("My name is James, what about you? Today's weather is good"); Boost: Split (vecsegtag, strtag2, boost :: is_any_of (_ T (","); For (size_t I = 0; I <vecsegtag. size (); I ++) {STD: wcout <vecsegtag [I] <STD: Endl;} getchar (); Return 0 ;}