Skip to content

Instantly share code, notes, and snippets.

@fuyufjh
Created April 4, 2017 13:30
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 fuyufjh/287b982ad97ea57337516e4f6a094c5f to your computer and use it in GitHub Desktop.
Save fuyufjh/287b982ad97ea57337516e4f6a094c5f to your computer and use it in GitHub Desktop.
split string in cpp
char *dup = strdup(str.c_str());
for (char *token = strtok(dup, " ,;"); token != NULL; token = strtok(NULL, " ,;")) {
// do something with token
}
free(dup);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment