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 101 102 103 104 105 106 107 108
| #include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
typedef struct perso {
char nom[21];
char prenom [21];
char datenaissance [11];
char adresse [31];
char telephone [11];
}bloc ;
int main()
{
void remplir(FILE* fichier,bloc nouv);
void acceuil ();
void menu();
void lister (FILE * fichier);
FILE * fichier;
bloc nouv ,temp;
char nomfich[11];
int choix;
clrscr();
MENU :
clrscr();
acceuil();
menu();
scanf ("%d",&choix);
{
switch (choix)
{
case 1 :
clrscr();
remplir(fichier,nouv);
break ;
case 4 :clrscr();
lister(fichier);
break ;
case 5 :
goto EXIT ;
}
}
goto MENU;
EXIT :
fclose(fichier);
return 0;
}
void acceuil ()
{
printf ("\n\n\n\n\n\t---BIENVENUE_AU_PROGRAMME_DE_GESTION_DE_PERSONNEL---\n");
};
void menu()
{
printf("\n\n\n\n\n\tENTRER UN CHOIX\n\n\n\n\n\n");
printf("***1->\t\t\t_AJOUT\n***2->\t\t\t_SUPPRESSION\n***3->\t\t\t_CHERCHER\n***4->\t\t\t_LIRE\n***5->\t\t\t_EXIT\n");
};
void lister (FILE * fichier)
{
bloc temp ;
fichier = fopen ("repp","r");
printf ("\n LISTE_DES_TRAVAILLEURS\n");
while (fread(&temp,sizeof(bloc),1,fichier),!feof(fichier))
{
printf("\n\nNom : %s \nPrenom : %s\ndate_naissance : %s\nAdresse : %s\nTel : %s",temp.nom,temp.prenom,temp.datenaissance,temp.adresse,temp.telephone);
getch();
}
fclose(fichier);
};
void remplir (FILE *fichier,bloc nouv)
{ fichier=fopen("repp","a");
puts("VEULLEIZ SAISISSEZ\n");
puts("**NOM ?**\n");
gets (nouv.nom);
puts("**PRENOM ?**\n");
gets (nouv.prenom);
puts("**DATE_DE_NAISSANCE ?**\n");
gets (nouv.datenaissance);
puts("**ADRESSE ?**\n");
gets (nouv.adresse);
puts("**TEL ?**\n");
gets (nouv.telephone);
fwrite(&nouv,sizeof(struct perso),1,fichier);
fclose(fichier);
}; |
Partager