All pastes #45171 Raw Edit

Anonymous

public c v1 · immutable
#45171 ·published 2006-03-10 18:50 UTC
rendered paste body
#include <stdio.h>#include <string.h>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;}