char **ft_split(char *str, char *charset)
{
int i = 0;
int index = 0;
int len;
if (condition(str[0], charset) != 1)
while (condition(str[index], charset) != 1)
index++;
while (condition(str[index], charset) == 1)
index++;
int tab = nbword(str, charset);
printf("%d, len\n\n", tab);
char **tableau = malloc((tab + 1) * sizeof(char));
while (str[index] != '\0')
{
while (condition(str[index], charset) == 1)
index++;
len = wordlen(str, index, charset);
tableau[i++] = malloc(len + 1 * sizeof(char));
ft_strSPcpy(tableau[i - 1], str, len - 1, index);
printf("tableau[%d] = %s\n", i - 1, tableau[i - 1]);
index += len;
}
tableau[i] = 0;
return tableau;
free(tableau);
}
this is where something blocks.
before main
tableau[0] = bodeg
tableau[1] = c vr
tableau[2] = iment
tableau[3] = uper
in function main
tableau[0] = tableau[last] = (null)
c vr
iment
uper
and this is what i get when executed.
so as you can see, in the main function, the first string is empty?? what happenned ?
i also tried to see after my last while, all strings were good.
thank you