Bonjour,
Comme le titre l'indique, un probleme de variable opere au moment du passage d'un double pointeur sur structure.
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 void moving_ants(char **tab, t_histo *ways, t_ant **anthill) { int nb_total; int current_ant; int dispo_way; t_ant *ptr; *anthill = NULL; nb_total = record_nb_fourmi(tab); current_ant = 0; dispo_way = 0; while (current_ant <= nb_total) { if (!create_ants(anthill, nb_total, current_ant, ways, &dispo_way)) { ptr = *anthill; printf("(1)Anthill = %x | *Anthill = %x | Anthill->next = %x\n", anthill, *anthill, ptr->next); aff_ants(anthill); /* Je fais appel ici a la fonction */ } current_ant++; } }Ce code continue mais je l'ai coupe car le probleme arrive avant.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 void aff_ants(t_ant **anthill) { char *room; char *nbr_of_ant; t_ant *ant; ant = *anthill; printf("(2)Anthill = %x | *Anthill = %x | Ant->next = %x\n", anthill, *anthill, ant->next); printf("(3)Ant->next = %x | Ant->nbr = %d | Ant->Way = %s\n", ant->next, ant->nbr_ant, ant->my_way); exit(0); }
Voici ce que j'obtiens sur la sortie standard :
(0)Anthill = bfbfe74c | *Anthill = bfbfe6d0 | Ant->next = 0
(1)Anthill = bfbfe74c | *Anthill = bfbfe6d0 | Anthill->next = 0
(2)Anthill = bfbfe74c | *Anthill = bfbfe6d0 | Ant->next = bfbfe6f8
(3)Ant->next = bfbfe6d0 | Ant->nbr = 134522492 | Ant->Way = Ðæ¿¿Pè
- Le (0) indique que les changements ont bien ete fait a la fin de la fonction create_ants().
- Le (1) indique que tout est correct, ca reste inchange.
- Et la, a partir du (2), c'est la debandade...
Le truc, c'est qu'aucune ecriture dans la memoire n'est faite, donc ce n'est sans doute meme pas lie a un mauvais malloc qui n'aurait pas assez liberer d'espace...
Bref, je n'ai aucune idee de quoi faire et c'est ce qui me pousse a vous demander votre aide.
Partager