void strnsplit(char *str, char c, int n, char dest[10][250]) { int i; int j; int k = 0; /* if the number of characters to split at is less than the number of * requested splits -- thats ok. * otherwise, the max # of splits must be the # of characters to split at */ int nc = scount_chars(str, c); n = (nc < n) ? n : nc; /* while there is still a string left to split */ for (i = 0; i < n; i++) { j = 0; /* while we're not at a split character, or the end of the string... */ while (str[k] != c && str[k] != '\0') { /* ...copy the current character... */ dest[i][j] = str[k]; /* ...increment the iterators */ j++; k++; } /* terminate the current string */ dest[i][j] = '\0'; k++; } }