Created
January 2, 2021 09:10
-
-
Save emadflash/a35ffb8ea8c78106f70656e7b3097aef to your computer and use it in GitHub Desktop.
split strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vector<string> | |
split(string& s, char delm){ | |
vector<string> elems; | |
auto it=begin(s); | |
while(it < end(s)){ | |
auto found = find(it, end(s), delm); | |
int dis = distance(it, found); | |
string elem = string(it, it+dis); | |
elems.push_back(elem); | |
it = next(found); | |
} | |
return elems; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment