Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <vector>
- using namespace std;
- vector<string> split(string str, char delimiter = ' ')
- {
- vector<string> ret;
- int start = 0;
- for(int i=0; i < str.length(); ++i) {
- if(str[i] == delimiter) {
- ret.push_back(str.substr(start, i-start));
- start = i+1;
- }
- }
- ret.push_back(str.substr(start, start - str.length()));
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement