Bonjour,
Toujours avec mes pointeurs je me heurte à un nouveau problème. J'ai créé une fonction NewStack() qui créé une pile tout beau tout propre avec le retour de cette pile créé mais après je n'arrive pas à utiliser correctement ce retour dans une autre fonction où je dois déclarer plusieurs piles, dans ce cas, ma fonction IsPalindrome().
J'ai un message erreur de ce type quand j'exécute:
exo.sh(1080,0x7fff74b9b300) malloc: *** error for object 0x7fce01404b68: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
Je n'ai pas trouvé de solutions, merci bien de vos réponses !
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 Stack NewStack() { int i; Stack new = malloc(sizeof(Stack)); for (i = 0; i < 100; ++i) { new->tab[i] = ' '; } new->summit = -1; return new; } int IsPalindrome(char tab[], int size) { Stack first = NewStack(); Stack second = NewStack(); int i; int test; for (i = 0; i < size; ++i) Push(first, tab[i]); if (size%2 == 0) }
Partager