[STL ] strtok c++版

看板C_and_CPP作者 (殺.人.鬼)時間15年前 (2010/06/05 18:00), 編輯推噓1(103)
留言4則, 2人參與, 最新討論串1/1
總覺得很多人想要在c++裡面用類似strtok功能的function,所以就心血來潮寫了一個 STL版的strtok http://nopaste.csie.org/eea98 範例用法: #include <iostream> #include "strtok.hpp" using namespace std; int main() { string a = ",-1- ,2"; string b = ", -"; for (strtok_iterator i(a, b), end; i != end; ++i) { cout << *i << endl; } } // output: // 1 // 2 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.123.225.77 ※ 編輯: ibmibmibm 來自: 140.123.225.77 (06/06 02:01)

06/06 02:16, , 1F
辛苦你了...但..
06/06 02:16, 1F

06/06 02:17, , 2F
Boost.Tokenizer 就是一個類似的現成品了。
06/06 02:17, 2F

06/06 02:17, , 3F

06/06 10:44, , 4F
推!推您的熱情
06/06 10:44, 4F
文章代碼(AID): #1C2f31al (C_and_CPP)