Created
August 27, 2017 18:13
-
-
Save EdoardoVignati/e662acabccb2d9750829ae685ee06c5b to your computer and use it in GitHub Desktop.
Tokenize a string in c
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
#include <string.h> | |
#include <stdio.h> | |
int main() | |
{ | |
char str[100] = "Try to token , this is a token , another token"; | |
const char s[2] = ","; | |
char *token; | |
/* Get the first token */ | |
token = strtok(str, s); | |
/* Walk through other tokens */ | |
while( token != NULL ) | |
{ | |
printf("%s\n", token); | |
token=strtok(NULL, s); | |
} | |
return(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment