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
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
//la structure des personnes
typedef struct participant
{
char *nom;
char *prenom;
char *fct;
char *chek;
}participant;
//insertion des infos sur le participant
void insertionp(participant *listep, char nvnom[30],char nvprenom[30],char nvfct[30],int i)
{
listep[i].nom=nvnom;
listep[i].prenom=nvprenom;
listep[i].fct=nvfct;
}
//afichage du tableau
void afficherp(participant *listep)
{
int i;
for(i=0;i<100 && listep[i].nom != NULL;i++)
{
printf("nom: %s\n", listep[i].nom);
printf("prenom: %s\n", listep[i].prenom);
printf("foncion: %s\n\n", listep[i].fct);
}
}
main(){
int cont =0, i=0;
char name[30], prename[30], fct[30];
participant *lp=(participant*)malloc(100*sizeof(participant));
//saisie de la liste des participants
while(cont == 0){
system("cls");
printf("nom:");
gets(name);
gets(name); //je doit ajouter ce gets !!!
printf("\nprénom:");
gets(prename);
printf("\nfonction:");
gets(fct);
insertionp(lp,name,prename,fct,i); //insertion dans le tableau des participants
i++;
printf("pour continuer taper 0");
scanf("%d",&cont);
}
afficherp(lp);
getch();
} |
Partager