Advertisement
JellyKuo

Cpp Split

Jun 6th, 2020
1,049
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. vector<string> split(string str, string delim)
  2. {
  3.     vector<string> result;
  4.     int last = 0;
  5.     int next = 0;
  6.     while ((next = str.find(delim, last)) != str.npos)
  7.     {
  8.         result.push_back(str.substr(last, next - last));
  9.         last = next + 1;
  10.     }
  11.     result.push_back(str.substr(last));
  12.  
  13.     return result;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement