Bonjours a toutes et a tous,
Voila mon probleme:
Dans mon programme C j'ai crée une liste (structure) qui contient struct liste suite et struct information InfoListe comme suite:
alors pour encoder mes info (plus qu'un) ca fonctionne tres bien mais pour l'affichage il me sort toujours le 1er que j'ai encoder et pour le reste il trouve pas ... Certrainement un prob de pointeur mais pas moyen de trouve
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 typedef struct { int ID; int num; int CP; int tel; char nom[Si]; char pre[Si]; char rue[Si]; char ville[Si]; }information; //Declaration de la structure Sliste struct liste { information InfoListe; struct liste *suite; }; typedef struct liste Sliste;
Dans mon main j'ai:
Pour inserer Encoder et Afficher j'ai les fonctions suivantes:
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 do { system("cls"); InsererElement(&deb); //Le & est necessaire pour le double pointeur NbrIns++; printf("Encoder un nouvel element ? ('o' pour continuer)"); fflush(stdin); scanf("%c",&again); }while(again == 'o' || again == 'O'); }break; //Afficher les element de la liste case 2: { for(i=0; i<NbrIns; i++) { system("cls"); AfficherInfo(&(deb+i)->InfoListe); getch(); } }break;
Merci d'avance pour l'aide que vous pourrez me fournir
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 void EncoderInfo(information *info) { system("cls"); printf("Entrer l'identifiant : "); fflush(stdin); scanf("%d",&info->ID); printf("Entrer votre nom : "); fflush(stdin); gets(info->nom); printf("Entrer votre prenom : "); fflush(stdin); gets(info->pre); printf("Entrer le numero : "); fflush(stdin); scanf("%d",&info->num); printf("Entrer votre rue : "); fflush(stdin); gets(info->rue); printf("Entrer le code postal: "); fflush(stdin); scanf("%d",&info->CP); printf("Entrer la ville : "); fflush(stdin); gets(info->ville); printf("Entrer le num de tel : "); fflush(stdin); scanf("%d",&info->tel); } //Declaration de la fonction AfficheInfo (uniquement avec la struct information) void AfficherInfo(information *info) { while(info) {printf("Votre identifiant: %d",info->ID); printf("\nVotre nom : "); puts(info->nom); printf("Votre prenom : "); puts(info->pre); printf("Votre numero : %d",info->num); printf("\nVotre rue : "); puts(info->rue); printf("Votre code postal: %d",info->CP); printf("\nVotre ville : "); puts(info->ville); printf("Votre telephone : %d",info->tel);} } void InsererElement(Sliste **deb) { Sliste *parcours,*inserer,*precedent; parcours = *deb; precedent = NULL; inserer=(Sliste*)malloc(sizeof(Sliste )); EncoderInfo(&((inserer)->InfoListe)); while (parcours !=NULL) { precedent = parcours; parcours = parcours->suite; } inserer->suite = parcours; if (precedent == NULL) { *deb=inserer; } else { precedent->suite = inserer; } }
Xillion
Partager