Created
July 16, 2012 00:16
-
-
Save alyx/3119347 to your computer and use it in GitHub Desktop.
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
CorcString **corcstr_split(CorcString *in, char sep) | |
{ | |
int i = 0; | |
char *instr, *ptr, *placeholder; | |
CorcString **out, *cs; | |
instr = strdup(in->string); | |
placeholder = instr; | |
while (ptr = strchr(placeholder, sep)) | |
{ | |
*ptr = '\0'; | |
out[i] = corcstr(placeholder); | |
placeholder = ptr+1; | |
++i; | |
} | |
if (placeholder) | |
{ | |
out[i] = corcstr(placeholder); | |
out[++i] = NULL; | |
} | |
else if (i == 0) | |
{ | |
free(instr); | |
return NULL; | |
} | |
free(instr); | |
return out; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment