Created
August 17, 2011 13:28
-
-
Save GabrielL/1151525 to your computer and use it in GitHub Desktop.
Simple use case for strsep
This file contains 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
#include <stdio.h> | |
#include <string.h> | |
/* | |
* Split the argument by ',' | |
*/ | |
int main(int argc, char **argv) | |
{ | |
char *token; | |
char *string = argv[1]; | |
for (token = strsep(&string, ","); token; token = strsep(&string, ",")) | |
{ | |
puts(token); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment