Programme de gestion de bibliothèque
salut
j'ai un mini projet qui consiste à gérer une gestion de bibliothèque
la démarche est la suivante :
j'affiche un menu qui présente les différentes fonctios[modification(suppression ,ajout), lister de livre(afficher)].
voila mon programme mais il n'execute plus :cry::cry:
aidez moi svp pour avoir un bon programme ;);)
Code:
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
| #include<stdio.h>
#include<stdlib.h>
#include<windows.h>
char choix2;
struct elementlivre
{int code;
char auteur[20];
char titre[20];
};
struct elementlivre infolivre;
typedef struct fonctions
{
struct elementlivre infolivre;
struct fonction *suivant;
}maillon;
typedef maillon *liste;
maillon* ajout(maillon* l)
{maillon nv=(maillon*)malloc(sizeof(maillon))
nv->code=infolivre.code;
nv->titre[20]=infolivre.titre[20];
nv->auteur[20]=infolivre.auteur[20];
maillon temp=l;
printf("entrer le code du livre:");
scanf("%d",nv->infolivre.code);
printf("entre le nom d'auteur:");
scanf("%c",&nv->infolivre.auteur[20]);
printf("entrer le titre du livre:");
scanf("%c",&nv->infolivre.titre[20]);
while(temp->suivant!=NULL)
{
temp=temp->suivant;
}
nv->suivant=NULL;
temp->suivant=nv;
return l;
}
maillon* suppression(maillon* l)
{ int x;
printf("entre le code de livre que vous voullez suprimer");
scanf("%d",&x);
maillon *p,*avp;
p=l;
avp=l;
printf("entrer le code du livre:");
scanf("%d",&x);
while((p->suivant!=NULL)&&(p->infolivre.code!=x))
avp=p;
p=p->suivant;
free(p);
return l;
}
maillon* modification(maillon* l)
{char choix1;
printf("ajout----->1");
printf("suppression------>2");
printf("quitter------->3");
printf("entrer votre choix:");
scanf("%c",&choix1);
switch (choix1)
{ case'1':l=ajout(l);
break;
case'2':l=suppression(l);
break;
case'3':exit(0);
default;
}
maillon* listerlivre(maillon* l)
{
liste temp;
while(temp!=NULL)
{
printf("%d",nv->infolivre.code);
printf("%c",nv->infolivre.auteur[20]);
printf("%c",nv->infolivre.titre[20]);
temp=temp->suivant;
}
return l;
}
void main()
{
printf("modification------>4");
printf("lister du livre------>5");
printf("quitter------->6");
printf("entrer votr choix");
scanf("%c",&choix2)
switch(choix2)
{
case'4':l=modification(l);
break;
case'5':l=listerlivre(l);
break;
case'6':exit(0);
default;
}
getch();
} |