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
| #include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
#include <windows.h>
#include "init/init.h"
#include "saisie/livre.h"
#include "saisie/auteur.h"
#include "saisie/editeur.h"
#include "menu/menuprot.h"
#include "save/save.h"
void main(void) {
// declaration des tableaux lies aux fichiers
// les differentes structures sont declarees dans init.h
st_aut *tab_auteur=NULL;
st_livre *tab_livre;
st_genre *tab_genre;
st_editeur *tab_editeur;
int test=10;
FILE * fic_auteur;
int nbEleA=-1;
int nbEleL=-1;
int nbEleG=-1;
int nbEleE=-1;
int vartmp=-1;
int retour_menu=0;
int i=0;
char saisie[150]="";
int tmp=0;
char chemin[255]="";
char chA[255]="";
// chemin ou est lance le processus
GetCurrentDirectory (255, chemin);
//chemin du fichier auteur
strncat(chA,chemin,strlen(chemin));
strcat(chA,"\\auteur.bin");
// initialisation des tableaux
tab_auteur = (st_aut*)malloc(sizeof(st_aut));
tab_livre = (st_livre*)malloc(sizeof(st_livre));
tab_genre = (st_genre*)malloc(sizeof(st_genre));
tab_editeur = (st_editeur*)malloc(sizeof(st_editeur));
/*#####################################################
# INITIALISATION DES NBS D ENREGISTREMENTS #
#####################################################*/
init_nb(&nbEleA,&nbEleL,&nbEleG,&nbEleE);
/*#####################################################
# REDIMENTIONNEMENT DES TABLEAUX #
#####################################################*/
tab_auteur = (st_aut*)realloc(tab_auteur, (nbEleA+1)*sizeof(st_aut));
tab_livre = (st_livre*)realloc(tab_livre, (nbEleL+1)*sizeof(st_livre));
tab_genre = (st_genre*)realloc(tab_genre, (nbEleG+1)*sizeof(st_genre));
tab_editeur = (st_editeur*)realloc(tab_editeur, (nbEleE+1)*sizeof(st_editeur));
/*#####################################################
# INITIALISATION DES TABLEAUX #
#####################################################*/
init( tab_auteur,tab_livre,tab_genre,tab_editeur,nbEleA, nbEleL,nbEleG, nbEleE) ;
/*-------------- FIN DES INITIALISATIONS -------------*/
for (i=0;i<=nbEleA;i++){
printf("auteur[%d].nom = %s\n",i,tab_auteur[i].nom);
}
do {
printf("main.nbElA = %d\n",nbEleA);
//printf("main.tab_auteur[0].nom = %s\n",tab_auteur[0].nom);
retour_menu=menuA();
switch (retour_menu) {
case 1: save_auteur(tab_auteur, nbEleA);break;
case 2: saisie_editeur(tab_editeur,&nbEleE); break;
case 3:
//tab_auteur = (st_aut*)realloc(tab_auteur, (nbEleA+2)*sizeof(st_aut));
saisie_auteur(tab_auteur, &nbEleA); break; |
Partager