Salut, je suis pas trés forte en language c mais j'essaye de me rattrapper, si vous voulez bien m'aider , merci d'avance, mon code est le suivant:
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
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
struct client{
char nom[30];
char prenom[30];
char adress[50];
int numcin;
int numcompte;
struct client *clsuivant;
struct client *clprecedant;
};
/*struct compte{
int numcompte;
float solde;
struct compte *cptsuiv;
};
/*struct date{
int jour;
int mois;
int annee;
struct date *dtsuiv;
};*/
void creerlist(struct client **tlist){
*tlist=NULL;
}
int ajoutClient(struct client **tlist,char nom[30],char prenom[30],int numcin,int numcompte){
struct client *plist;
plist=(struct client*)malloc(sizeof(struct client));
strcpy(plist->nom, nom);
strcpy(plist->prenom, prenom);
plist->clsuivant=*tlist;
plist->numcin=numcin;
plist->numcompte=numcompte;
*tlist=plist;
return 0;
}
void affichlist(struct client *tlist){
struct client*p;
 
for(p=tlist;p!=NULL;p=p->clsuivant){
printf("\nNom:%s\n",p->nom);
printf("Prenom:%s\n",p->prenom);
printf("NumCIN:%d\n",p->numcin);
printf("Numcompte:%d\n",p->numcompte);
}
getch();
}
int supClient(struct client **tlist,int numcompte){
struct client *cl,*clprecedant;
if(*tlist==NULL) return 0;
//if(*tlist->client.numcompte==numcompte){
//precCL=*cl->*tlist;
for(cl=*tlist;(cl!=NULL && cl->numcompte!=numcompte);cl=cl->clsuivant){
clprecedant->clsuivant=cl->clsuivant;
cl->clsuivant->clprecedant=clprecedant;
free(cl);
}
return 1;
}
 
 
 
int main(){
struct client *tlist,*plist;
char nom[30];
char prenom[30];
int numcin;
int numcompte;
char cont,cont2;
clrscr();
creerlist(&tlist);
do{
printf("Nom:");
fflush(stdin);
gets(nom);
printf("\nPr‚nom:");
fflush(stdin);
gets(prenom);
printf("\nNum‚ro C.I.N:");scanf("%d",&numcin);
printf("\nNum‚ro Compte:");scanf("%d",&numcompte);
ajoutClient(&tlist,nom,prenom,numcin,numcompte);
printf("\n\tAutre client … ajout‚(o\\n)?");
fflush(stdin);
scanf("%c",&cont);
}while(cont=='o');
affichlist(tlist);
do{
printf("\nentrer le numcompte du client … supprimer:");
scanf("%d",&numcompte);
supClient(&tlist,numcompte);
printf("\n\t autre client … supprimer(o\\n)?");
fflush(stdin);
scanf("%c",&cont2);
}while(cont2=='o');
affichlist(tlist);
getch();
return 0;
}
la création/ l'affichage de la liste des clients fonctionne , mais pas la suppression.
Mon probléme est : il y a une faute au niveau de la suppression, svp, pourriez vous la corriger, merci