Bonjour;
j'ai une erreur qui me soule alors j'en deduit qu'il y a un truck que j'ai pas pigé :/
J'ai isolé le pbm .. :
resultat :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 #include <sys/time.h> #include <sys/types.h> char **mots = 0;int nbmots = 0; int *fcts = 0; //ajouter une commande void ajMot(char* mot, int fct){ printf("%d\n", nbmots); if (mots == 0){ mots = malloc(++nbmots); fcts = malloc(nbmots); }else { mots = realloc(mots, ++nbmots); fcts = realloc(fcts, nbmots); } fcts[nbmots-1] = fct; mots[nbmots-1] = malloc(strlen(mot)+1); strcpy(mots[nbmots-1], mot); mots[nbmots-1][strlen(mot)+1] = 0; } int main(void) { ajMot("help2", 0); ajMot("help", 0); ajMot("helpjj", 0); ajMot("helpjhuhuk", 0); ajMot("hkjhjklelpjhuhuk", 0); ajMot("helphhjhuhuk", 0); ajMot("helpjpppoohuhuk", 0); return (0); }
*** glibc detected *** realloc(): invalid next size (fast) : etc..
Une idée ?
Partager