Skip to content

Instantly share code, notes, and snippets.

@gitzhou
Created March 3, 2015 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gitzhou/cab00f3492cdc795e445 to your computer and use it in GitHub Desktop.
Save gitzhou/cab00f3492cdc795e445 to your computer and use it in GitHub Desktop.
C++ split function
vector<int> &split(const string &s, char delim, vector<int> &elems) {
stringstream ss(s);
string item;
while(getline(ss, item, delim)) {
elems.push_back(atoi(item.c_str()));
}
return elems;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment