Bonjour,
je suis (debutante) en langage c.
la fonction charger() contient tjs des erreurs est ce que quelqu'un peut me la corriger.
merci bcp d'avance

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<malloc.h>
#include<string.h>
#include "arbre.h"
#ifdef DEBUG
 #include <time.h>
 time_t intps;
 #define log(x) \
  intps = time(NULL);\
  printf("%s %s %s\n",__FILE__,strtok(ctime(&intps),"\n"),x); 
#else
 #define log(x)
#endif
 
 
/*-------------------------------------------------------*/
a_fichier *charger()
{
 FILE *fp;
 char s[100];
 a_fichier *racine;
 racine=NULL;
 log("ouverture du fichier...\n");
 //fp=fopen("C:\\Documents and Settings\\nourddine\\workspace\\rihabTP\\fof.txt","r");
 fp=fopen("fof.txt","r");
 if(!fp){
  log("le fichier n'exite pas");
  return(NULL);
    }
    log("lecture du fichier ...\n");
 
 while(fgets(s,100,fp))
  insere_noeud(&racine,s);
 fclose(fp);
 return(racine);
}
 
/*////////////////////////////////////////////////////////////////////////////////////*/
/* case 1:Afficher les données d'un noeud defini par un chemin donne*/
 
void insere_noeud(a_fichier **racine,char *s)
{
 char nom_pere[30];
 fichier d;
 a_fichier *pere, *p;
 extraire(s,nom_pere,&d);
 pere=seek_noeud(*racine,nom_pere);
 p=(a_fichier *) malloc(sizeof(a_fichier));
 p->d=d;
 p->fils=NULL;
  if(!pere)
  {
   p->frere=racine;
   *racine=p;
  }
  else
  {
   p->frere=pere->fils;
   pere->fils=p;
  }
}
/*________________________________________________________________*/
a_fichier *seek_noeud(a_fichier *racine,char *nom)
{
   a_fichier *p;
   if(!racine) return(NULL);
   if(!strcmp(racine->d.chemin,nom));
       return(racine);
  if(p=seek_noeud(racine->fils,nom))
    return(p);
  return(seek_noeud(racine->frere,nom));
}
/*________________________________________________________________*/
void extraire(char *s, char *nom, fichier *d)
{
 //possibilité de dépassement !!!
 sscanf(s,"%51s%2s%11s%11s",d->chemin,d->type,d->taille,d->d_creation);
}
 
/*________________________________________________________________*/
void view_noeud(a_fichier *racine,char *ch)
{
 int n;
  if(racine)
  {
   printf("%s\n",ch);
   printf("%s\n",racine->d.chemin);
    if(strcmp(racine->d.chemin,ch)|| !ch)
    {
 
 
  //printf("Chemin: %s\n",racine->d.chemin);
  printf("Type: %s\n",racine->d.type);
  printf("Taille: %s\n",racine->d.taille);
  printf("Date de creation: %s\n",racine->d.d_creation);
    }
    else
    {
      view_noeud(racine->fils,ch);
      view_noeud(racine->frere,ch);
    }
  }
}
et voici le fichier texte
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
c: R 0 01/01/2006
c:\logiciel R 0 02/01/2006
c:\logiciel\langage_c R 0 03/01/2006
c:\logiciel\langage_c\tp1.c F 2000 04/01/2006
c:\logiciel\langage_c\tp2.c F 3000 05/01/2006
c:\documents R 0 06/01/2006
c:\documents\invitation.doc F 2500 07/01/2006
c:\documents\word R 0 08/01/2006
c:\documents\word\version1 R 0 09/01/2006
c:\documents\word\version2 R 0 09/01/2006
c:\documents\word\version1\offre1.doc F 1500 10/01/2006
c:\documents\word\version2\offre1.doc F 1500 10/01/2006
d: R 0 01/02/2006
d:\prolog R 0 02/02/2006
d:\prolog\td1.doc F 1230 03/02/2006
d:\prolog\td2.doc F 1780 04/02/2006
d:\java R 0 05/02/2006
d:\java\tp1 R 0 05/02/2006
d:\java\tp1\allocateur.java F 3600 06/02/2006
d:\java\tp2 R 0 07/02/2006
d:\java\tp2\mv.java F 10000 08/02/2006