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
|
#include <conio.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
FILE* sp = NULL;
FILE* pe = NULL;
sp=fopen("spectacle.dat","r+b");
pe=fopen("event.dat","r+b"); /*fichier ou l'on saisie les events*/
int i, tot_event; /*i et tot_event sont initialisées*/
struct evenement
{
char show [30]; /*structure event*/
int mois;
int jour;
int place_reserve[50][60];
};
if (errno==0)
{
if (sp != NULL)
{
fseek(sp,0,SEEK_SET);
fread(&tot_event,sizeof(int), 1, sp);
printf("%d",tot_event);
fclose(sp);
}
evenement actu[tot_event]; /*structure chargé*/
if (pe != NULL)
{
fseek(pe,0,SEEK_SET);
fread(&actu[1],sizeof(struct evenement), 1, pe);
printf("%s %d %d",actu[1].show, actu[1].mois, actu[1].jour);
}
fclose(pe);
}else perror("erreur ouverture");
system("PAUSE");
return 0;
} |
Partager