#include #include void strnsplit(char *in, char c, int n, char **dest) { int i; int j; for (i = 0; i < n; i++) { j = 0; while (in[j] != c) { printf("%c, ", in[j]); dest[i][j] = in[j]; j++; } printf("\n"); dest[i][j] = '\0'; } } int main() { char foo[50] = "abcd,efgh,ijkl,mnop"; char bar[10][50]; strnsplit(foo, ',', 4, bar); int i; for (i=0; i<4; i++) { printf("%s\n", bar[i]); } return 0; }