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
| /*
* ex1.c
*
* Created on: 2 jan. 2016
* Author: khalil
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
/*struct enfant
{
char prenom[20];
int annee ;
enfant *suivant;
};
typedef struct enfant Enfant;*/
struct employee
{
char *nomPrenom;
int matricule ;
int date;
//Enfant *enf;
struct employee *succ;
};
typedef struct employee Employee;
void insertion_employee(Employee *L)
{
Employee *p;
char *s="bonjour";
int mat;
int dte;
//Enfant *enf;
printf("donner le nom et le prénom de l'employé");
fflush(stdout);
scanf("%s\n",s);
p=(Employee*)malloc(sizeof(Employee));
p->nomPrenom=s;
printf("donner la matricule de l'employé");
fflush(stdout);
scanf("%d",&mat);
p->matricule=mat;
printf("donner l'année de naissance de l'employé");
fflush(stdout);
scanf("%d",&dte);
p->date=dte;
p->succ = L;
}
void affiche_employee(Employee *L)
{
Employee *p;
p=L;
while(p)
{
printf("le nom et le prénom de l'employé : %s \n",p->nomPrenom);
fflush(stdout);
printf("la matricule : %d \n",p->matricule);
fflush(stdout);
printf("l'année de naissance : %d \n",p->date);
fflush(stdout);
p=p->succ;
printf("***************** \n");
}
}
int main()
{
Employee *L=NULL;
char rep;
printf("voulez vous insérer un employé ? o/n \n");
fflush(stdout);
rep=getchar();
while (rep=='o')
{
insertion_employee(L);
printf("voulez vous insérer un employé ? o/n \n");
fflush(stdout);
rep=getchar();
}
affiche_employee(L);
free(L);
system("pause");
return 0 ;
} |
Partager