Skip to content

Instantly share code, notes, and snippets.

@emadflash
Created January 2, 2021 09:10
Show Gist options
  • Save emadflash/a35ffb8ea8c78106f70656e7b3097aef to your computer and use it in GitHub Desktop.
Save emadflash/a35ffb8ea8c78106f70656e7b3097aef to your computer and use it in GitHub Desktop.
split strings
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