Bonjour,
J'ai un soucis, je cherche à remplir un tableau en "réallocant" à chaque fois. Voici la tronche de ma fonction :
char **body(char *file)
{
char **tab;
char *str;
int fd;
int i;
i = 0;
if ((fd = check_file(file)) == -1)
return (NULL);
str = NULL;
tab = my_xmalloc(sizeof(*tab));
while ((str = get_next_line(fd)) != NULL)
{
tab[i] = str;
my_xrealloc(tab, (i + 2 * sizeof(*tab)));
i++;
}
tab[i] = NULL;
return (tab);
}
Le soucis c'est que je rammasse tout ce qu'il faut dans mon tableau sauf le premier caractère qui est complètement aléatoire...
Réponses pertinentes 