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
|
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int code_etudiant;
char nom[15];
char prenom[15];
float moy_annee;
char mention[9];
} etudiant;
int main(int argc, char *argv[])
{
etudiant e;
FILE *f; /*f est un nom logique*/
f=fopen("c:/fiche_eleve","wb+");
if(f==NULL){
printf("creation non faite");
}
fwrite(&e,sizeof(e),1,f);
printf("entrer le code nom prenom et la moyanne generale:\n");
scanf("%d %s %s %f",&e.code_etudiant,&e.nom,&e.prenom,&e.moy_annee);
fread(&e,sizeof(e),1,f);
printf("le code=%d nom %s prenom %s moyenne %f",e.code_etudiant,e.nom,e.prenom,e.moy_annee);
fclose(f);
system("PAUSE");
return 0;
} |
Partager