bonjour,

je suis débutante en langage c et je veux programmer un arbre binaire, j'ai commencé avec le code suivant mais il m'affiche des erreurs
creationarbre.h
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
 
#ifndef __TREE__H__
#define __TREE__H__
 
#include <stdio.h>
#include <stdlib.h>
 
typedef struct Tree
 
{
   	int value;
	struct Tree *left;
	struct Tree *right;
	struct Tree *parent;
}Tree;
 
Tree *new_tree(int x)
 
 
#endif
creationarbre.c

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
#include "creationarbre.h"
 
Tree *new_tree(int x)
{
     Tree *tr=malloc(sizeof(*tr));
 
     if (tr==NULL)
     {
        fprintf(stderr,"erreur\n");
        exit(EXIT_FAILURE);                       
     }
 
     tr->value=x;
     tr->left=NULL;
     tr->right=NULL;
     tr->parent=NULL;
 
 
     printf("creation de %d\n",tr->value);
 
     return tr;
 
}
main.c
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
#include "creationarbre.h"
 
int main(void)
{
 Tree *Arbre=new_tree(2);
 
 return 0;   
 
}

apres execution l'erreur suivante s'affiche:

C:\Dev-Cpp\proj\mainn.c In function `main':
5 C:\Dev-Cpp\proj\mainn.c `Tree' undeclared (first use in this function)
(Each undeclared identifier is reported only once
for each function it appears in.)
5 C:\Dev-Cpp\proj\mainn.c `Arbre' undeclared (first use in this function)