c++ split ()

c++ code:
Split(const string& s, const string& delimiter, vector<string>* result)
{
  size_t last = 0;
  size_t index = s.find_first_of(delimiter, last);
  while (index != string::npos)
  {
    result->push_back(s.substr(last, index - last));
    last = index + 1;
    index = s.find_first_of(delimiter, last);
  }
  if (index - last > 0)
  {
    result->push_back(s.substr(last, index - last));
  }
}
發佈了72 篇原創文章 · 獲贊 4 · 訪問量 24萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章