Dico avec les listes chainée

Fermé
pittfc25 Messages postés 4 Date d'inscription mardi 13 septembre 2011 Statut Membre Dernière intervention 22 décembre 2011 - 22 déc. 2011 à 15:36
Bonjour,
je suis debutant dans langage c et je veux construire un dectionaire voila mn code


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<windows.h>


typedef char ch1[255];
typedef char ch2[30] ;
typedef struct no{ch2 c;ch1 b ;ch2 k[6];int n;struct no *svt;}list;
typedef struct{char a;list *svt;}elem;
typedef elem Dico[26];
/*fonction trv h[i]*/
list*find(ch2 b,Dico h)
{
list*v=NULL;
int i;
while(i<26)
{
if(h[i].a==b[0])
{
v=h[i].svt;i=28;
}
i++;
}
return(v);
}
/*fonction qui recherch le mot */
list *rech(ch2 b,Dico h)
{ list *p,*q;
q=NULL;
int a;
p=find(b,h);
if(p==NULL)return(q);

else
a=strcmp(b,p->c);
if(a==0)return(p);
else
while(p->svt !=NULL)
{
p=p->svt;
a=strcmp(b,p->c);
if (a==0)return(p);
}
return(q);



}
list*cree()
{
list *p;
p =(list*)malloc(sizeof(list));
if(!p) {printf ("erreur d'allocation");
exit(-1);}

return(p);
}
/*fonction qui remplit la structure list*/
list *remp()
{list *p;int a,i;
p=cree();
printf("faite entrer votre mot");
scanf("%s",p->b);
printf("donnez la definition de ce mot");
scanf("%s",p->b);
printf("nombre de synonymes: ");
{scanf("%d",&a);}
p->n=a;
for(i=0;i<a;i++)
{
printf("donner le mot %d ",i+1);
scanf("%s",p->k[i]);
}
p->svt=NULL;
return(p);
}

/*fonction qui ajoute un mot avec la def et tt*/

void ajout(Dico h)
{
list *q,*p;
p=remp();
q=(list*)malloc(sizeof(list));
q=find(p->c,h);
if(q==NULL)
{
int i;
while(i<26)
{
if(h[i].a==p->c[0])
{
i=28;
}
i++;
}
h[i].svt=p;

}
if(q!=NULL)
{
if(q->svt==NULL)q->svt=p;
else
{
q=q->svt;
while(q->svt!=NULL)
q=q->svt;

q->svt=p;
}
}
}
/*fonction qui cherch la def*/
void def(Dico h)
{
ch2 a;list *p;
printf("donner votre mote");
gets(a);
p=rech(a,h);
if(p==NULL)
printf("Le mote n'existe pas");
else
{
printf("La défintion est: ");
puts(p->c);
}
}
/*fonction qui cherch les synms*/
void syn(Dico h)
{
ch2 a;list *p;
printf("donner votre mote");
gets(a);
p=rech(a,h);
if(p==NULL)
printf("Le mote n'existe pas");
else
{
int i;
printf("les synonymes: \n");
for(i=0;i<p->n;i++)
puts(p->k[i]);
}
}

void menu()
{

printf( " 0__________MENU_____________0\n");
printf( " | | \n");
printf( " | 1/ Recherche | \n");
printf( " | | \n");
printf( " | 2/ Trouver Definition | \n");
printf( " | | \n");
printf( " | 3/ Trouver des synonyms | \n");
printf( " | | \n");
printf( " | 4/ Ajouter un mot |\n");
printf( " | | \n");
printf( " |___________________________|\n");
printf( " 0 0\n");
printf("Quelle tache vous voulez executez:");


}

main()
{
int i,s=1;
list*p,*q;
ch2 v;
Dico h;char A[30] ="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
q=remp();
for(i=0;i<26;i++)
{
h[i].a=A[i];
h[i].svt=q;
}


while(s>=1 && s<5)
{
menu();

scanf("%d",&s);


if(s==1)
{
printf("Tapez votre mot AVEC UNE LETTRE MAJISCULE au debut \n");
scanf("%s",v);
p=rech(v,h);
if(p==NULL)printf("Le mot n'existe pas !! \n");
else {printf("le mot %s existe",v);}
}
if(s==2)
{
printf("Tapez votre mot AVEC UNE LETTRE MAJISCULE au debut");
scanf("%s",v);
p=rech(v,h);
if(p==NULL)
printf("Le mot n'existe pas !! ");
else
{printf("La definition est: \n");puts(p->c);}
}

if(s==3)
{
printf("Tapez votre mot AVEC UNE LETTRE MAJISCULE au debut");
scanf("%s",v);
p=rech(v,h);
if(p==NULL)printf(" \n Le mot n'existe pas !! ");
else
{printf("Les synonymes sont: \n");
for(i=0;i<p->n;i++)
puts(p->k[i]);
}
}
if(s==4)
{
ajout(h);
}


}
}

probleme avec l'erreur césse de fonctionner ...... SVP aidez moi