Skip to content

Instantly share code, notes, and snippets.

@helsont
Created November 24, 2015 00:46
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 helsont/fa95009c5c61255e65f1 to your computer and use it in GitHub Desktop.
Save helsont/fa95009c5c61255e65f1 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
char *str1, *str2, *token, *subtoken;
char *saveptr1, *saveptr2;
int j;
char banger[] = "629: {Hello?} said {fdkmwsfokasdfasdfasd}";
char tokens[] = ":}{";
for (j = 1, str1 = banger; ;j++, str1 = NULL) {
token = strtok(str1, tokens);
if (token == NULL)
break;
fprintf(stderr, "%d: %s\n", j, token);
}
return 0;
}
OUTPUT:
1: 629
2:
3: Hello?
4: said
5: fdkmwsfokasdfasdfasd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment