#include #include //char ** strsplit ( char*,char); char ** strsplit ( char * fichier, char sep ) { printf("entree dans strsplit"); int nbsep = 0; int cpt = 0; while ( fichier[cpt] != '\0' ) { nbsep += (fichier[cpt] == sep ? 1 : 0); cpt ++; } printf("%d bloc differents",cpt); int i = 0, offset = 0, offsetchar = 0; char ** tab = malloc((cpt + 1)*sizeof(char*)) ; printf("tab init"); //tab[cpt] = NULL; printf("%p", tab[cpt+1]); for ( i =0; i < cpt+1; i ++ ) { tab[i] = malloc ( 100 * sizeof(char)); } i =0; cpt = 0; while ( fichier[i] != '\0' ) { if (fichier[i] != sep) { tab[offset][offsetchar] = fichier[i]; offsetchar ++; cpt ++; } else { tab[offset][offsetchar]='/0'; tab[offset] = realloc ( tab[offset], (cpt) * sizeof(char)); offset++; offsetchar = 0; cpt = 0 ; } } return tab; } int main (int argc, char ** argv) { int i=0,cpt=0; printf("jusqu'ici tout va bien"); char ** tableau = strsplit(argv[1], argv[2][0]); while (tableau[i]!=NULL) { while (tableau[i][cpt]!='\0') { printf("%c",tableau[i][cpt]); cpt ++; } printf("\n"); i ++; } return 0;}