Created
April 4, 2017 13:30
-
-
Save fuyufjh/287b982ad97ea57337516e4f6a094c5f to your computer and use it in GitHub Desktop.
split string in cpp
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
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