Created
April 30, 2018 19:11
-
-
Save miquels/b30eaf8a6a60c5aafc86e1703eca1f9b to your computer and use it in GitHub Desktop.
Demo voor mies
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> | |
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