Salut chers développeurs!
J'ai un petit problème pour l'accés à des données d'un tableau de type structure.
Voici mon code:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!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 typedef struct{ char *nom; int note; }etudiant; etudiant e; etudiant *tab_etud; void saisie(){ printf("Donner le nombre d'etudiant: "); scanf("%d",&nb); tab_etud=(etudiant*)malloc(nb*sizeof(etudiant)); if(tab_etud!=NULL){ for(i=0;i<nb;i++){ printf("\n\t\tEtudiant %d\n",i); printf("\tNom: "); scanf("%s",&e.nom); printf("\n\tSa note: "); scanf("%d",&e.note); tab_etud[i]=e; } } } void affiche(){ for(i=0;i<nb;i++){ printf("\t%s-->%d\n",tab_etud[i].nom,tab_etud[i].note); } }
je suis arrivé à saisir le nom d'un etudiant et sa note mais j'ai un problème pour l'affichage!
ça m'a déjà faire perdre des nuits et je compte sur votre aide mes chers pour y remédier.
Cordialement ELDE!