Salut, alors voila j ai fais des fonctions d'ajout et d'affichage du contenu d'un arbre binaire, mais je sais pas pourkoi il affiche en plus des elements contenu dans l'arbre, un chiffre qui est en fait une adresse ( de je ne sais quoi ). Pouvez vous m'aider ?
voici mon programme
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
typedef struct ARBRE
{
int fruit;
struct ARBRE *fg;
struct ARBRE *fd;
};
void ajouter(ARBRE**,int);
void afficher(ARBRE*);
main()
{
/////////////////////////////////////////////////////
ARBRE ab,*pab;
int x;
ab.fg=NULL;
ab.fd=NULL;
pab=&ab;
printf("Ajoutez un element a l'arbre\n");
for(int i=0;i<6;i++)
{
printf("\n");
scanf("%d",&x);
printf("\n");
ajouter(&pab,x);
}
printf("\n\n\n\n");
afficher(pab);
system("PAUSE");
/////////////////////////////////////////////////////
}
void ajouter(ARBRE **ab, int nb)
{
if (*ab==NULL)
{
*ab=(ARBRE*)malloc(sizeof(ARBRE));
(*ab)->fruit=nb;
(*ab)->fg=NULL;
(*ab)->fd=NULL;
}
else
{
if (nb>(*ab)->fruit)
ajouter(&(*ab)->fd,nb);
else
ajouter(&(*ab)->fg,nb);
}
}
void afficher(ARBRE *ab)
{
if (ab!=NULL)
{
//printf("-%d-",ab->fruit);
afficher(ab->fg);
//printf("-%d-",ab->fruit);
afficher(ab->fd);
printf("-%d-",ab->fruit);
}
}
Voila merci d'avance pour votre aide