Bonjour, j'ai voulu declarer deux tableau dynamique de char ( chaine de caractere) dont je ne sais pas la taille j'ai procédé de la facon suivante:
et j'ai inséré dans une boucle while le coe suivant:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 char* chaine; char* chaine1;
mé lors de la compilation une erreur de ce type surgit:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 if (k==0) chaine= malloc (sizeof(char)); else chaine = realloc (chaine,sizeof(chaine)+sizeof(char)); chaine[k]=chain[i]; k++; if (l==0) chaine1= malloc (sizeof(char)); else chaine1 = realloc (chaine1,sizeof(chaine1)+sizeof(char)); chaine1[l]=chain[i]; l++;
alors j'étais sur qu'il y a un probleme avec l'allocation que j'ai fait
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 projet1(6875) malloc: *** error for object 0x100554: incorrect checksum for freed object - object was probably modified after being freed. *** set a breakpoint in malloc_error_break to debug projet1(6875) malloc: *** error for object 0x100564: incorrect checksum for freed object - object was probably modified after being freed. *** set a breakpoint in malloc_error_break to debug projet1(6875) malloc: *** error for object 0x100574: incorrect checksum for freed object - object was probably modified after being freed. *** set a breakpoint in malloc_error_break to debug projet1(6875) malloc: *** error for object 0x100570: incorrect checksum for freed object - object was probably modified after being freed. *** set a breakpoint in malloc_error_break to debug
merci de me repondre
Partager