Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 0.35 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. void split(std::string& s, std::string& delim,std::vector<std::string>* ret)
  2. {
  3.         size_t last = 0;
  4.         size_t index = s.find_first_of(delim, last);
  5.         while (index != std::string::npos)
  6.         {
  7.                 ret->push_back(s.substr(last, index-last));
  8.                 last = index+1;
  9.                 index = s.find_first_of(delim, last);
  10.         }
  11.         if (index-last > 0)
  12.         {
  13.                 ret->push_back(s.substr(last, index-last));
  14.         }
  15. }