Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <stdexcept>
- using namespace std;
- vector<string> Split(const string& str, const string& delim = " ") {
- vector<string> answer;
- int begword = 0;
- int endword = 0;
- while(str.find(delim, endword) != str.npos)
- {
- begword = str.find(delim, endword);
- if(str.find(delim, begword) == str.npos)
- {
- int sz = str.size();
- endword = sz;
- }
- else
- endword = str.find(delim, begword);
- answer.push_back(str.substr(begword, endword - begword));
- endword--;
- }
- return answer;
- throw std::runtime_error("Not implemented");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement