Advertisement
Guest User

Untitled

a guest
Oct 29th, 2015
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <string>
  2. #include <sstream>
  3. #include <vector>
  4.  
  5. std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems, size_t max_count = size_t(-1)) {
  6.     std::stringstream ss(s);
  7.     std::string item;
  8.     while (elems.size() < max_count && std::getline(ss, item, delim)) {
  9.         elems.push_back(item);
  10.     }
  11.     return elems;
  12. }
  13.  
  14.  
  15. std::vector<std::string> split(const std::string &s, char delim, size_t max_count = size_t(-1)) {
  16.     std::vector<std::string> elems;
  17.     split(s, delim, elems, max_count);
  18.     return elems;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement