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
|
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include "AFFi.h"
#define KMAX 50
int main(void)
{
//declaration
typedef
struct
{
char numero[6];
char nom[25];
char annee;
}
Inscrits;
Inscrits unEtu;
FILE * desc3;
//initialisation
nbEtu1=0;
nbEtu2=0;
desc3=fopen("Etudiants.iut","rt");
if(desc3!=NULL)
{
fread(&unEtu,sizeof(Inscrits),1,desc3);
for(i=0;i<10;i++)
{
printf("Numero %s \n",unEtu.numero);
printf("Nom %s \n",unEtu.nom);
printf("Annee %c \n",unEtu.annee);
fread(&unEtu,sizeof(Inscrits),1,desc3);
}
fclose(desc3);
}
if(unEtu.annee=='1') // Si le numero de l'annee de l Etudiant est egal à 1 (premiere année) alors le traitement ... ça reste ambigu ici !
{
desc4=fopen("Etudiants.1a","wt");
if(desc4!=NULL)
{
printf("%s",unEtu.numero);
printf("%s",unEtu.nom);
printf("%c",unEtu.annee);
fwrite(&unEtu,sizeof(Inscrits),1,desc4);
nbEtu1++;
}
fclose(desc4);
}
if(unEtu.annee=='2') // Si le numero de l'annee de l'Etudiant est egal à 2 ( second année) alors le traitement suivant...ambigu ici aussi !
{
desc5=fopen("Etudiants.2a","wt");
if(desc5!=NULL)
{
for(i=0;i<10;i++)
{
printf("%s",unEtu.numero);
printf("%s",unEtu.nom);
printf("%c",unEtu.annee);
fwrite(&unEtu,sizeof(Inscrits),1,desc5);
nbEtu2++;
}
fclose(desc5);
}
}
getche();
return 0;
} |
Partager