Use boost library in engineering: (Set VS2010 environment)
Add D:\boost\boost_1_46_0\bin\vc10\lib to the library files
Add D:\boost\boost_1_46_0 to include files
1 //boostTest.cpp: Defines the entry point of the console application. 2#include"stdafx.h"3 4#include <iostream>5#include <boost/format.hpp>6#include <boost/tokenizer.hpp>7#include <boost/algorithm/string.hpp>8 9 int_tmain (intARGC, _tchar*argv[])Ten { OneStd::wcout.imbue (Std::locale ("CHS")); A //string to be split -Std::wstring Strtag = _t ("I Come from China"); - theStd::vector<std::wstring>Vecsegtag; - //boost::is_any_of Here is the equivalent of a split 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; A } at - vecsegtag.clear (); -Std::wstring StrTag2 = _t ("My name is pony, and you're fine today, I'm glad"); -Boost::split (Vecsegtag, StrTag2, boost::is_any_of (_t (",,"))); - - for(size_t i =0; I<vecsegtag.size (); i++) in { -std::wcout<<vecsegtag[i]<<Std::endl; to } + - GetChar (); the return 0; *}
Boost::split Usage Explanation