生活随笔
收集整理的這篇文章主要介紹了
boost使用split分割字符串
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
工程中使用boost庫:(設定vs2010環境)
在Library files加上 D:\boost\boost_1_46_0\bin\vc10\lib
在Include files加上 D:\boost\boost_1_46_0
使用舉例:
[cpp]?view plaincopy
?? #include?"stdafx.h"?? ?? #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"));???? ?????? ????std::wstring?strTag?=?_T("I?Come?from?China");???? ?? ????std::vector<std::wstring>?vecSegTag;???? ?????? ????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("我叫小馬,你呢,今天天氣不錯,我很高興");???? ????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;???? } ?
總結
以上是生活随笔為你收集整理的boost使用split分割字符串的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。