Skip to content

Instantly share code, notes, and snippets.

@miquels
Created April 30, 2018 19:11
Show Gist options
  • Save miquels/b30eaf8a6a60c5aafc86e1703eca1f9b to your computer and use it in GitHub Desktop.
Save miquels/b30eaf8a6a60c5aafc86e1703eca1f9b to your computer and use it in GitHub Desktop.
Demo voor mies
#include <stdio.h>
#include <string.h>
int str_split(char *in, char *out[2])
{
out[0] = strtok(in, "=");
out[1] = strtok(NULL, "=");
return out[1] == NULL ? -1 : 0;
}
int main()
{
char *teststr = strdup("hello=world");
char *kv[2];
if (str_split(teststr, kv) == 0) {
printf("succes! [%s] [%s]\n", kv[0], kv[1]);
} else {
printf("fail\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment