bistou Vieux .... très très vieux! Transactions (0) | Code :
- #include <stdio.h>
- #include <conio.h>
- #include <string.h>
- struct bibli
- {
- int numero;
- int volume;
- char titre[20];
- char auteur[20];
- char edition[10];
- char date[9];
- };
- struct biblise
- {
- int num;
- int volu;
- char titr[20];
- char aut[20];
- char edit[10];
- char dat[9];
- };
- struct biblia
- {
- int numeroa;
- int volumea;
- char titrea[20];
- char auteura[20];
- char editiona[10];
- char datea[9];
- };
- void creationprem (int);
- void creationsec (int);
- void affichf ();
- void listprem (struct bibli,int);
- void listsec (struct biblise,int);
- void ajout (struct bibli,struct biblise,int,struct biblia);
- int recherche (struct bibli,int,struct biblise,int);
- void affich2 (struct bibli);
- void supprimp (struct bibli,int,struct biblise,int);
- int rechvide (struct biblise,int);
- void affich3 (struct biblise);
- void modification (struct bibli,int,struct biblise,int);
- main()
- {
- FILE *pt,*ps;
- int x,nbmaxfich=1000,nbmaxse=900,pass=4849,code;
- struct bibli vbib={0,0,"","",""};
- struct biblise vbibse={-1,0,"","",""};
- struct biblia vbiba={0,0,"","",""};
- char menu=49,listage=49,ecra='n';
- clrscr();
- pt=fopen("file.dat","rb" );
- if (pt==0)
- {
- creationprem(nbmaxfich);
- creationsec (nbmaxse);
- }
- else
- {
- printf ("\n\nVoulez-vous ecraser les fichiers exsistants (o/n): " );
- ecra=getche();
- if (ecra=='o')
- {
- printf ("\nEntrez le passe: " );
- fflush(stdin);
- scanf("%d",&code);
- if (pass==code)
- {
- creationprem (nbmaxfich);
- creationsec (nbmaxse);
- }
- else
- {
- printf("\nVous n'avez pas l'autorisation d'?craser les fichiers" );
- fflush(stdin);
- getch();
- }
- }
- }
- while (menu!=54)
- {
- menu=48;
- listage=48;
- clrscr();
- printf ("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿" );
- gotoxy(1,2);printf("³" );gotoxy(78,2);printf("³" );
- gotoxy(1,3);printf("³" );gotoxy(78,3);printf("³" );
- gotoxy(1,4);printf("³" );gotoxy(78,4);printf("³" );
- gotoxy(1,5);printf("³" );gotoxy(78,5);printf("³" );
- gotoxy(1,6);printf("³" );gotoxy(78,6);printf("³" );
- gotoxy(1,7);printf("³" );gotoxy(78,7);printf("³" );
- gotoxy(1,8);printf("³" );gotoxy(78,8);printf("³" );
- gotoxy(1,9);printf("³" );gotoxy(78,9);printf("³" );
- gotoxy(1,10);printf("³" );gotoxy(78,10);printf("³" );
- gotoxy(1,11);printf("³" );gotoxy(78,11);printf("³" );
- gotoxy(1,12);printf("³" );gotoxy(78,12);printf("³" );
- gotoxy(1,13);printf("³" );gotoxy(78,13);printf("³" );
- gotoxy(1,14);printf("³" );gotoxy(78,14);printf("³" );
- gotoxy(1,15);printf("³" );gotoxy(78,15);printf("³" );
- gotoxy(1,16);printf("³" );gotoxy(78,16);printf("³" );
- gotoxy(1,17);printf("³" );gotoxy(78,17);printf("³" );
- gotoxy(1,18);printf("³" );gotoxy(78,18);printf("³" );
- gotoxy(1,19);printf("³" );gotoxy(78,19);printf("³" );
- gotoxy(1,20);printf("³" );gotoxy(78,20);printf("³" );
- gotoxy(1,21);printf("³" );gotoxy(78,21);printf("³" );
- gotoxy(1,22);printf("³" );gotoxy(78,22);printf("³" );
- gotoxy(1,23);printf("³" );gotoxy(78,23);printf("³" );
- gotoxy(1,24);printf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
- ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
- " );
- textcolor(BLUE);
- gotoxy(19,2);cprintf("Application 2002" );
- gotoxy(38,2);cprintf("B5" );
- gotoxy(43,2);cprintf("Menu principal" );
- textcolor(LIGHTGRAY);
- gotoxy(17,2);puts ("³" );
- gotoxy(36,2);printf("³" );
- gotoxy(41,2);printf("³" );
- gotoxy(58,2);printf("³" );
- gotoxy(17,3);puts ("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ" );
- gotoxy(4,8);printf ("1.Lister les fiches." );
- gotoxy(4,9);printf("2.Ajouter une fiche." );
- gotoxy(4,10);printf("3.Supprimer une fiche." );
- gotoxy(4,11);printf("4.Modifier une fiche." );
- gotoxy(4,12);printf("5.Rechercher une fiche." );
- gotoxy(4,13);printf("6.Quitter le programme." );
- do
- {
- gotoxy(17,16);
- printf ("Votre choix: " );
- fflush(stdin);
- menu=getche();
- }
- while (menu<49 || menu>54);
- switch (menu)
- {
- case 49:while (listage!=51)
- {
- clrscr();
- textcolor(RED);
- gotoxy(3,3);cprintf("Menu de listage:" );
- textcolor(LIGHTGRAY);
- gotoxy(1,1);printf ("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿" );
- gotoxy(1,2);printf("³" );gotoxy(78,2);printf("³" );
- gotoxy(1,3);printf("³" );gotoxy(78,3);printf("³" );
- gotoxy(1,4);printf("³" );gotoxy(78,4);printf("³" );
- gotoxy(1,5);printf("Ã" );gotoxy(78,5);printf("³" );
- gotoxy(2,5);printf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
- ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ" )
- ;
- gotoxy(1,6);printf("³" );gotoxy(78,6);printf("³" );
- gotoxy(1,7);printf("³" );gotoxy(78,7);printf("³" );
- gotoxy(1,8);printf("³" );gotoxy(78,8);printf("³" );
- gotoxy(1,9);printf("³" );gotoxy(78,9);printf("³" );
- gotoxy(1,10);printf("³" );gotoxy(78,10);printf("³" );
- gotoxy(1,11);printf("³" );gotoxy(78,11);printf("³" );
- gotoxy(1,12);printf("³" );gotoxy(78,12);printf("³" );
- gotoxy(1,13);printf("³" );gotoxy(78,13);printf("³" );
- gotoxy(1,14);printf("³" );gotoxy(78,14);printf("³" );
- gotoxy(1,15);printf("³" );gotoxy(78,15);printf("³" );
- gotoxy(1,16);printf("³" );gotoxy(78,16);printf("³" );
- gotoxy(1,17);printf("³" );gotoxy(78,17);printf("³" );
- gotoxy(1,18);printf("³" );gotoxy(78,18);printf("³" );
- gotoxy(1,19);printf("³" );gotoxy(78,19);printf("³" );
- gotoxy(1,20);printf("³" );gotoxy(78,20);printf("³" );
- gotoxy(1,21);printf("³" );gotoxy(78,21);printf("³" );
- gotoxy(1,22);printf("³" );gotoxy(78,22);printf("³" );
- gotoxy(1,23);printf("³" );gotoxy(78,23);printf("³" );
- gotoxy(1,24);printf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
- ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
- " );
- gotoxy(4,7);printf ("1.Lister le fichier primaire" );
- gotoxy(4,8);printf ("2.Lister le fichier secondaire" );
- gotoxy(4,9);printf ("3.Retour au menu principal" );
- do
- {
- gotoxy(10,12);printf (" Votre choix: " );
- fflush(stdin);
- listage=getche();
- }
- while (listage<49 || listage>51);
- switch (listage)
- {
- case 49:listprem (vbib,nbmaxfich);
- break;
- case 50:listsec (vbibse,nbmaxse);
- break;
- }
- }
- break;
- case 50: clrscr();
- printf ("\n\t\tÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»" );
- printf ("\n\t\tº AJOUT D'UNE FICHE º" );
- printf ("\n\t\tÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ" );
- ajout(vbib,vbibse,nbmaxse,vbiba);
- break;
- case 51: clrscr();
- printf ("\n\t\tÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»" );
- printf ("\n\t\tº SUPPRESSION D'UNE FICHE º" );
- printf ("\n\t\tÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ" );
- supprimp (vbib,nbmaxfich,vbibse,nbmaxse);
- break;
- case 52: clrscr();
- printf ("\n\t\tÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»" );
- printf ("\n\t\tº MODIFICATION D'UNE FICHE º" );
- printf ("\n\t\tÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ" );
- modification (vbib,nbmaxfich,vbibse,nbmaxse);
- break;
- case 53: clrscr();
- printf ("\n\t\tÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»" );
- printf ("\n\t\tº RECHERCHE D'UNE FICHE º" );
- printf ("\n\t\tÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ" );
- x=recherche(vbib,nbmaxfich,vbibse,nbmaxse);
- if (x>=nbmaxfich+1)
- {
- x=x-2000;
- ps=fopen("filsec.dat","rb" );
- fread(&vbibse,sizeof(vbibse),1,ps);
- fseek(ps,(x-1)*sizeof(vbibse),0);
- if (vbibse.num!=-1)
- {
- if (x<=nbmaxse)
- {
- fseek(ps,(x)*sizeof(vbibse),0);
- fread(&vbibse,sizeof(vbibse),1,ps);
- affich3(vbibse);
- fflush(stdin);
- getch();
- }
- }
- else
- {
- printf ("\n\nCette fiche n'exsiste pas." );
- fflush(stdin);
- getch();
- }
- fclose(ps);
- }
- else
- {
- pt=fopen("file.dat","rb" );
- fseek(pt,(x-1)*sizeof(vbib),0);
- fread(&vbib,sizeof(vbib),1,pt);
- if (vbib.numero!=0)
- {
- fseek(pt,(x-1)*sizeof(vbib),0);
- fread(&vbib,sizeof(vbib),1,pt);
- affich2(vbib);
- fflush(stdin);
- getch();
- fclose(pt);
- }
- else
- {
- printf ("\n\nCette fiche a ?t? supprim?e." );
- fflush(stdin);
- getch();
- }
- }
- break;
- }
- }
- }
- /*//////////////////////////////FONCTIONS/////////
- ///////////////////////*/
-
- /*////////////////////CREATION DU FICHIER PRIMAIRE///////////////////////*/
-
- void creationprem (int nbmaxfich)
- {
- FILE *pt;
- struct bibli vbib={0,0,"","","",""};
- int i;
-
- pt=fopen("file.dat","wb" );
- for (i=1;i<=nbmaxfich;i++)
- {
- fwrite(&vbib,sizeof(vbib),1,pt);
- }
- fclose(pt);
- }
-
- /*////////////////////////////////////////////////
- ////////////////////*/
-
- void creationsec (int nbmaxse)
- {
- FILE *pt;
- struct biblise vbibse={-1,0,"","","",""};
- int i;
-
- pt=fopen("filsec.dat","wb" );
- for (i=1;i<=nbmaxse;i++)
- {
- fwrite(&vbibse,sizeof(vbibse),1,pt);
- }
- fclose(pt);
- }
-
- /*////////////////////////////////////////////////
- ////////////////////*/
-
- void affichf (void)
- {
- printf ("\nCl? Volume Titre Auteur Edition Date" );
- printf ("\nÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
- ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ" );
- }
-
- /*////////////////////////////////////////////////
- ////////////////////*/
-
- void listprem (struct bibli vbib,int nbmaxfich)
- {
- FILE *pt;
- int comp2=0,comp4=0,comp3=0,comp=1,rep=0;
-
- pt=fopen("file.dat","rb" );
- clrscr();
- affichf();
- do
- {
- fread(&vbib,sizeof(vbib),1,pt);
- comp3++;
- if (vbib.numero!=0)
- {
- comp++;
- comp2++;
- if (comp2%20==0)
- comp2=0;
- gotoxy(1,comp2+4);printf ("%d",vbib.numero);
- gotoxy(9,comp2+4);printf ("%d",vbib.volume);
- gotoxy(16,comp2+4);printf ("%s",vbib.titre);
- gotoxy(43,comp2+4);printf ("%s",vbib.auteur);
- gotoxy(59,comp2+4);printf ("%s",vbib.edition);
- gotoxy(70,comp2+4);printf ("%s",vbib.date);
- }
- if (comp%20==0 || comp3>=nbmaxfich)
- {
- textcolor(RED);
- gotoxy(1,25);
- cprintf ("ENTER pour poursuivre, ESC pour revenir au menu principal..." );
- textcolor(LIGHTGRAY);
- fflush(stdin);
- rep=getch();
- if (rep==13)
- {
- clrscr();
- affichf();
- }
- comp=1;
- }
- }
- while (comp3<=nbmaxfich && rep!=27);
- fclose(pt);
- }
-
- /*////////////////////////////////////////////////
- //////////////////////*/
-
- void listsec (struct biblise vbibse,int nbmaxse)
- {
- FILE *pt;
- int comp2=0,comp3=0,comp=1,rep=0;
-
- pt=fopen("filsec.dat","rb" );
- clrscr();
- affichf();
- do
- {
- for (;comp3<=nbmaxse;comp3++)
- {
- fread(&vbibse,sizeof(vbibse),1,pt);
- comp3++;
- if (vbibse.num!=-1)
- {
- comp++;
- comp2++;
- if (comp2%20==0)
- comp2=0;
- gotoxy(1,comp2+4);printf ("%d",vbibse.num);
- gotoxy(9,comp2+4);printf ("%d",vbibse.volu);
- gotoxy(16,comp2+4);printf ("%s",vbibse.titr);
- gotoxy(40,comp2+4);printf ("%s",vbibse.aut);
- gotoxy(56,comp2+4);printf ("%s",vbibse.edit);
- gotoxy(67,comp2+4);printf ("%s",vbibse.dat);
- }
- }
- if (comp%20==0 || comp3>=nbmaxse)
- {
- textcolor(RED);
- gotoxy(1,25);
- cprintf ("ENTER pour poursuivre, ESC pour revenir au menu principal..." );
- textcolor(LIGHTGRAY);
- fflush(stdin);
- rep=getch();
- if (rep==13)
- {
- clrscr();
- affichf();
- }
- comp=1;
- }
- }
- while (comp3<=nbmaxse && rep!=27);
- fclose(pt);
- }
-
- /*////////////////////////////////////////////////
- //////////////////////*/
-
- void ajout (struct bibli vbib,struct biblise vbibse,int nbmaxse,struct biblia vbiba)
- {
- FILE *pt,*ps,*pa;
- int k,i,comp=0,comp2=0,test2,nbfich,test,pad,pos;
- float cle=0;
- long id;
- char menu='',temp1[40],oui='o',lect[3],path[12]="",nom1[40],nom2[40];
-
- while (menu!=51)
- {
- clrscr();
- textcolor(RED);
- gotoxy(3,3);cprintf("Menu d'ajout:" );
- textcolor(LIGHTGRAY);
- gotoxy(1,1);printf("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
- ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
- " );
- gotoxy(1,2);printf("³" );gotoxy(78,2);printf("³" );
- gotoxy(1,3);printf("³" );gotoxy(78,3);printf("³" );
- gotoxy(1,4);printf("³" );gotoxy(78,4);printf("³" );
- gotoxy(1,5);printf("Ã" );gotoxy(78,5);printf("³" );
- gotoxy(2,5);printf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
- ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ" )
- ;
- gotoxy(1,6);printf("³" );gotoxy(78,6);printf("³" );
- gotoxy(1,7);printf("³" );gotoxy(78,7);printf("³" );
- gotoxy(1,8);printf("³" );gotoxy(78,8);printf("³" );
- gotoxy(1,9);printf("³" );gotoxy(78,9);printf("³" );
- gotoxy(1,10);printf("³" );gotoxy(78,10);printf("³" );
- gotoxy(1,11);printf("³" );gotoxy(78,11);printf("³" );
- gotoxy(1,12);printf("³" );gotoxy(78,12);printf("³" );
- gotoxy(1,13);printf("³" );gotoxy(78,13);printf("³" );
- gotoxy(1,14);printf("³" );gotoxy(78,14);printf("³" );
- gotoxy(1,15);printf("³" );gotoxy(78,15);printf("³" );
- gotoxy(1,16);printf("³" );gotoxy(78,16);printf("³" );
- gotoxy(1,17);printf("³" );gotoxy(78,17);printf("³" );
- gotoxy(1,18);printf("³" );gotoxy(78,18);printf("³" );
- gotoxy(1,19);printf("³" );gotoxy(78,19);printf("³" );
- gotoxy(1,20);printf("³" );gotoxy(78,20);printf("³" );
- gotoxy(1,21);printf("³" );gotoxy(78,21);printf("³" );
- gotoxy(1,22);printf("³" );gotoxy(78,22);printf("³" );
- gotoxy(1,23);printf("³" );gotoxy(78,23);printf("³" );
- gotoxy(1,24);printf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
- ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
- " );
- gotoxy(5,8);printf("1.Ajouter ? partir d'un fichier" );
- gotoxy(5,9);printf("2.Ajouter manuellement" );
- gotoxy(5,10);printf("3.Quitter" );
- do
- {
- gotoxy(18,15);printf("Votre choix: " );
- fflush(stdin);
- menu=getche();
- }
- while (menu<49 || menu>51);
- switch(menu)
- {
- case 49:
-
-
- while (oui=='o')
- {
- do
- {
- clrscr();
- printf ("Entrez la lettre du lecteur contenant le fichier, suivit de ':'" );
- printf ("\n\t>> " );
- fflush(stdin);
- gets(lect);
- test2=strlen(lect);
- if (test2!=2 || lect[1]!=':')
- {
- textcolor(RED);
- cprintf ("\nVeuillez entrez un lecteur correct" );
- textcolor(LIGHTGRAY);
- }
- }
- while(test2!=2 || lect[1]!=':');
- strcat(lect,"\\" );
- strcpy(temp1,lect);
- printf ("\nEntrez maintenant le repertoire dans lequel se trouve votre fichier" );
- printf ("\n\t>> " );
- fflush(stdin);
- gets (path);
- if (path[0]!='\x0')
- {
- strcat(temp1,path);
- strcat(temp1,"\\" );
- }
- printf ("\nEntrez, pour finir, le nom du fichier suivit de son exstention .dat" );
- printf ("\n\t>> " );
- fflush(stdin);
- gets(nom2);
- strcat(temp1,nom2);
- gotoxy(45,10);printf ("%s",temp1);
- textcolor(BLUE);
- gotoxy(1,9);cprintf ("\nVoici donc le chemin complet du fichier: " );
- textcolor(LIGHTGRAY);
- printf ("\n\nVoulez vous changer, et encoder un autre nom (o/n): " );
- fflush(stdin);
- oui=getche();
- }
- do
- {
- printf ("\n\nCombien de fiches voulez vous ajouter au fichier: " );
- fflush(stdin);
- scanf ("%d",&nbfich);
- if (nbfich<0 || nbfich>=999)
- {
- clrscr();
- textcolor(RED);
- cprintf ("\nVeuillez entrez un nombre correct 0<1000" );
- textcolor(LIGHTGRAY);
- }
- }
- while (nbfich<0 || nbfich>=999);
- pa=fopen(temp1,"rb" );
- pt=fopen("file.dat","r+b" );
- while (comp<nbfich && comp2<=1000)
- {
- if (comp2==1000 && comp==0)
- {
- textcolor(RED);
- cprintf ("\nLe fichier est vide ou n'a pas ?t? trouv?..." );
- textcolor(LIGHTGRAY);
- fflush(stdin);
- getch();
- }
- fread(&vbiba,sizeof(vbiba),1,pa);
- comp2++;
- if (vbiba.numeroa!=0)
- {
- id=vbiba.numeroa;
- pad=(id%1000)+1;
- fseek(pt,(pad-1)*sizeof(vbib),0);
- fread(&vbib,sizeof(vbib),1,pt);
- if (vbib.numero!=0)
- {
- pos=rechvide (vbibse,nbmaxse);
- ps=fopen("filsec.dat","r+b" );
- fseek(ps,(pos)*sizeof(vbibse),0);
- vbibse.num=vbiba.numeroa;
- vbibse.volu=vbiba.volumea;
- strcpy(vbibse.titr,vbiba.titrea);
- strcpy(vbibse.aut,vbiba.auteura);
- strcpy(vbibse.edit,vbiba.editiona);
- strcpy(vbibse.dat,vbiba.datea);
- fwrite(&vbibse,sizeof(vbibse),1,ps);
- fclose(ps);
- comp++;
- }
- else
- {
- vbib.numero=vbiba.numeroa;
- vbib.volume=vbiba.volumea;
- strcpy(vbib.titre,vbiba.titrea);
- strcpy(vbib.auteur,vbiba.auteura);
- strcpy(vbib.edition,vbiba.editiona);
- strcpy(vbib.date,vbiba.datea);
- fseek(pt,(pad-1)*sizeof(vbib),0);
- fwrite(&vbib,sizeof(vbib),1,pt);
- comp++;
- }
- }
- }
- fclose(pa);
- fclose(pt);
-
- break;
- case 50:
-
-
- clrscr();
- pt=fopen("file.dat","r+b" );
- do
- {
- printf ("\n\nVeuillez entrer un identifiant ( 1<9999 ): " );
- fflush(stdin);
- scanf ("%f",&cle);
- while (cle>9999 || cle<1)
- {
- clrscr();
- textcolor(RED);
- cprintf ("\nVeuillez entrez un idantifiant correct ( 1<9999 )" );
- textcolor(LIGHTGRAY);
- printf ("\n\nEntrez le nouvel idantifiant: " );
- fflush(stdin);
- scanf("%f",&cle);
- }
- id=cle;
- pad=(id%1000)+1;
- fseek(pt,(pad-1)*sizeof(vbib),0);
- fread(&vbib,sizeof(vbib),1,pt);
- if (vbib.numero==cle)
- {
- clrscr();
- printf ("\n\nCet idantifiant est deja utilis?" );
- }
- }
- while (vbib.numero==cle);
- if (vbib.numero!=0)
- {
- fclose(pt);
- pos=rechvide (vbibse,nbmaxse);
- ps=fopen("filsec.dat","r+b" );
- for (k=0;k<=nbmaxse;k++)
- {
- fseek(ps,(k)*sizeof(vbibse),0);
- fread(&vbibse,sizeof(vbibse),1,ps);
- if (vbibse.num==cle)
- {
- do
- {
- clrscr();
- printf("\nCet idantifiant est deja utilis?" );
- printf("\nVeuillez rentrer un nouvel idantifiant ( 1<9999 ): " );
- fflush(stdin);
- scanf("%f",&cle);
- while (cle>9999 || cle<1)
- {
- clrscr();
- textcolor(RED);
- cprintf ("\nVeuillez entrez un idantifiant correct ( 1<9999 )" );
- textcolor(LIGHTGRAY);
- printf ("\n\nEntrez le nouvel idantifiant: " );
- fflush(stdin);
- scanf("%f",&cle);
- }
- k=0;
- }
- while(vbibse.num==cle);
- }
- }
- fseek(ps,(pos)*sizeof(vbibse),0);
- vbibse.num=cle;
- printf ("\nEntrez le nø de volume: " );
- fflush(stdin);
- scanf("%d",&vbibse.volu);
- while (vbibse.volu<1 || vbibse.volu>15000)
- {
- clrscr();
- textcolor(RED);
- cprintf("\nAttention, le num?ro de volume doit etre un chiffre comprit 1 et 15000!" );
- textcolor(LIGHTGRAY);
- printf("\n\nVeuillez r?entrer un num?ro de volume: " );
- fflush(stdin);
- scanf("%d",&vbibse.volu);
- }
- printf ("\nEntrez le titre: " );
- fflush(stdin);
- gets (vbibse.titr);
- printf ("\nEntrez le nom de l'auteur: " );
- fflush(stdin);
- gets (vbibse.aut);
- printf ("\nEntrez le nom de l'editeur: " );
- fflush(stdin);
- gets (vbibse.edit);
- do
- {
- printf ("\nEntrez la date: " );
- fflush(stdin);
- gets (vbibse.dat);
- test=strlen(vbibse.dat);
- if (test!=8)
- {
- clrscr();
- textcolor(RED);
- cprintf ("la date doit etre encod?e de cette mani?re: **/**/**\n" );
- textcolor(LIGHTGRAY);
- }
- }
- while(test!=8);
- fwrite(&vbibse,sizeof(vbibse),1,ps);
- fclose(ps);
- }
- else
- {
- pt=fopen("file.dat","r+b" );
- fseek(pt,(pad-1)*sizeof(vbib),0);
- vbib.numero=cle;
- fflush(stdin);
- printf ("\nEntrez le nø de volume: " );
- fflush(stdin);
- scanf("%d",&vbib.volume);
- while (vbib.volume<1 || vbib.volume>15000)
- {
- clrscr();
- textcolor(RED);
- cprintf("\nAttention, le num?ro de volume doit etre un chiffre comprit 1 et 15000!" );
- textcolor(LIGHTGRAY);
- printf("\n\nVeuillez r?entrer un num?ro de volume: " );
- fflush(stdin);
- scanf("%d",&vbib.volume);
- }
- printf ("\nEntrez le titre: " );
- fflush(stdin);
- gets (vbib.titre);
- printf ("\nEntrez le nom de l'auteur: " );
- fflush(stdin);
- gets (vbib.auteur);
- printf ("\nEntrez le nom de l'editeur: " );
- fflush(stdin);
- gets (vbib.edition);
- do
- {
- printf ("\nEntrez la date: " );
- fflush(stdin);
- gets (vbib.date);
- test=strlen(vbib.date);
- if (test!=8)
- {
- clrscr();
- textcolor(RED);
- cprintf ("la date doit etre encod?e de cette mani?re: **/**/**\n" );
- textcolor(LIGHTGRAY);
- }
- }
- while(test!=8);
- fwrite(&vbib,sizeof(vbib),1,pt);
- fclose(pt);
- }
-
-
- break;
- }
- }
- }
-
- /*////////////////////////////////////////////////////////////////////*/
-
- int recherche (struct bibli vbib,int nbmaxfich,struct biblise vbibse,int nbmaxse)
- {
- FILE *ps,*pt;
- int i,c=1,x;
- char nom[30];
-
- printf ("\n\nEntrez le titre de la fiche a rechercher: " );
- fflush(stdin);
- gets(nom);
- fflush(stdin);
- pt=fopen("file.dat","rb" );
- for (i=0;i<=nbmaxfich || c==0;i++)
- {
- fread(&vbib,sizeof(vbib),1,pt);
- c=stricmp(vbib.titre,nom);
- if(c==0)
- {
- x=(vbib.numero%1000)+1;
- return(x);
- }
- }
- if (i>nbmaxfich)
- {
- ps=fopen("filsec.dat","rb" );
- for (i=0;i<=nbmaxse+1 || c==0;i++)
- {
- fread(&vbibse,sizeof(vbibse),1,ps);
- if (vbibse.num!=-1)
- {
- c=stricmp(vbibse.titr,nom);
- if (c==0)
- {
- i=i+2000;
- return(i);
- }
- }
- if (i>nbmaxse)
- {
- printf ("\n\nCe livre n'exsiste pas" );
- fflush(stdin);
- getch();
- i=i+2000;
- return(i);
- }
- }
- }
- fclose(ps);
- fclose(pt);
- return(i);
- }
-
- /*////////////////////////////////////////////////
- ///////////////////*/
-
- int rechvide (struct biblise vbibse,int nbmaxse)
- {
- FILE *pt;
- int i;
-
- pt=fopen("filsec.dat","rb" );
- for (i=0;i<=nbmaxse+1 || vbibse.num==-1;i++)
- {
- fread(&vbibse,sizeof(vbibse),1,pt);
- if(vbibse.num==-1)
- {
- return(i);
- }
- if (i==nbmaxse+1)
- {
- printf ("\n\nLe fichier est plein, impossible d'ajouter une fiche" );
- fflush(stdin);
- getch();
- }
- }
- fclose(pt);
- }
-
- /*///////////////////////////////////////////////////////////////////*/
-
- void affich2 (struct bibli vbib)
- {
- clrscr();
- gotoxy(1,2);printf ("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿" );
- gotoxy(1,3);printf ("³ Identifiant: " );
- textcolor(RED);
- gotoxy(17,3);cprintf("%d",vbib.numero);
- textcolor(LIGHTGRAY);
- gotoxy(29,3);printf("³" );
- printf ("\nÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄij" );
- printf ("\n³ Nøde volume : %d ",vbib.volume);
- gotoxy(29,5);printf("³" );
- gotoxy(29,6);printf("³" );
- gotoxy(29,7);printf("³" );
- gotoxy(1,6);printf ("³ Titre : %s ",vbib.titre);
- gotoxy(29,8);printf("³" );
- gotoxy(29,9);printf("³" );
- gotoxy(1,7);printf ("³ Auteur : %s ",vbib.auteur);
- gotoxy(1,8);printf ("³ Edition : %s ",vbib.edition);
- gotoxy(1,9);printf ("³ Date : %s ",vbib.date);
- gotoxy(1,10);printf ("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ" );
- }
-
- /*////////////////////////////////////////////////
- ///////////////////*/
-
- void affich3 (struct biblise vbibse)
- {
- clrscr();
- gotoxy(1,2);printf ("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿" );
- gotoxy(1,3);printf ("³ Identifiant: " );
- textcolor(RED);
- gotoxy(17,3);cprintf("%d",vbibse.num);
- textcolor(LIGHTGRAY);
- gotoxy(29,3);printf("³" );
- printf ("\nÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄij" );
- printf ("\n³ Nøde volume : %d ",vbibse.volu);
- gotoxy(29,5);printf("³" );
- gotoxy(29,6);printf("³" );
- gotoxy(29,7);printf("³" );
- gotoxy(29,9);printf("³" );
- gotoxy(1,6);printf ("³ Titre : %s ",vbibse.titr);
- gotoxy(1,7);printf ("³ Auteur : %s ",vbibse.aut);
- gotoxy(1,8);printf ("³ Edition : %s ",vbibse.edit);
- gotoxy(29,8);printf("³" );
- gotoxy(1,9);printf ("³ Date : %s ",vbibse.dat);
- gotoxy(1,10);printf ("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ" );
- }
-
- /*////////////////////////////////////////////////
- ///////////////////*/
-
- void supprimp (struct bibli vbib,int nbmaxfich,struct biblise vbibse,int nbmaxse)
- {
- FILE *pt,*ps;
- int pad,pad1,pad2,k,flag=0;
- char rep;
-
- pad=recherche(vbib,nbmaxfich,vbibse,nbmaxse);
- if (pad!=2901)
- {
- if (pad>=nbmaxfich+1)
- {
- if (pad>2000)
- {
- pad=pad-2000;
- printf ("\n\nVOULEZ VOUS VRAIMENT SUPPRIMER CETTE FICHE (o/n)" );
- rep=getche();
- if (rep=='o')
- {
- ps=fopen("filsec.dat","r+b" );
- fseek(ps,(pad)*sizeof(vbibse),0);
- fread(&vbibse,sizeof(vbibse),1,ps);
- vbibse.num=-1;
- fseek(ps,(pad)*sizeof(vbibse),0);
- fwrite(&vbibse,sizeof(vbibse),1,ps);
- clrscr();
- printf ("\nCette fiche a ?t? supprim?e." );
- fflush(stdin);
- fclose(ps);
- getch();
- }
- else
- {
- clrscr();
- printf ("\n\n\nSuppression annul?e." );
- }
- }
- }
- else
- {
- if (pad<nbmaxfich+1)
- {
- fflush(stdin);
- printf ("\n\nVOULEZ VOUS VRAIMENT SUPPRIMER CETTE FICHE (o/n)" );
- rep=getche();
- if (rep=='o')
- {
- pt=fopen("file.dat","r+b" );
- ps=fopen("filsec.dat","r+b" );
- fread(&vbibse,sizeof(vbibse),1,ps);
- fseek(pt,(pad-1)*sizeof(vbib),0);
- fread(&vbib,sizeof(vbib),1,pt);
- k=1;
- do
- {
- fseek(ps,(k-1)*sizeof(vbibse),0);
- fread(&vbibse,sizeof(vbibse),1,ps);
- pad1=(vbib.numero%1000)+1;
- pad2=(vbibse.num%1000)+1;
- if (pad1==pad2)
- {
- flag=1;
- vbib.numero=vbibse.num;
- vbibse.num=-1;
- vbib.volume=vbibse.volu;
- strcpy(vbib.titre,vbibse.titr);
- strcpy(vbib.auteur,vbibse.aut);
- strcpy(vbib.edition,vbibse.edit);
- strcpy(vbib.date,vbibse.dat);
- fseek(ps,(k-1)*sizeof(vbibse),0);
- fwrite(&vbibse,sizeof(vbibse),1,ps);
- fseek(pt,(pad-1)*sizeof(vbib),0);
- fwrite(&vbib,sizeof(vbib),1,pt);
- fclose(ps);
- }
- k++;
- }
- while (k<=nbmaxse && flag==0);
- if (k>=nbmaxse)
- {
- vbib.numero=0;
- fseek(pt,(pad-1)*sizeof(vbib),0);
- fwrite(&vbib,sizeof(vbib),1,pt);
- fclose(pt);
- }
- printf ("\nCette fiche a ?t? supprim?e." );
- fflush(stdin);
- getch();
- }
- else
- {
- printf ("\n\n\nSuppression annul?e." );
- fflush(stdin);
- getch();
- }
- }
- }
- }
- fclose(pt);
- }
-
- /*////////////////////////////////////////////////
- /////////////////////*/
-
- void modification (struct bibli vbib,int nbmaxfich,struct biblise vbibse,int nbmaxse)
- {
- FILE *pt,*ps;
- char rep,titre[40]="",auteur[40]="",date[9]="",editeur[40]="";
- int posi,volume=0,menu=49;
-
- posi=recherche(vbib,nbmaxfich,vbibse,nbmaxse);
- if (posi>=nbmaxfich+1)
- {
- posi=posi-2000;
- if (posi<nbmaxse+1)
- {
- ps=fopen("filsec.dat","r+b" );
- fseek(ps,(posi)*sizeof(vbibse),0);
- fread(&vbibse,sizeof(vbibse),1,ps);
- if (vbibse.num==-1)
- {
- clrscr();
- printf("Cette fiche a deja ?t? supprim?e." );
- fflush(stdin);
- getch();
- }
- else
- {
- while(menu!=54)
- {
- clrscr();
- textcolor(RED);
- gotoxy(3,3);cprintf("Menu de modification:" );
- textcolor(LIGHTGRAY);
- gotoxy(1,1);printf("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
- ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
- " );
- gotoxy(1,2);printf("³" );gotoxy(78,2);printf("³" );
- gotoxy(1,3);printf("³" );gotoxy(78,3);printf("³" );
- gotoxy(1,4);printf("³" );gotoxy(78,4);printf("³" );
- gotoxy(1,5);printf("Ã" );gotoxy(78,5);printf("³" );
- gotoxy(2,5);printf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
- ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ" )
- ;
- gotoxy(1,6);printf("³" );gotoxy(78,6);printf("³" );
- gotoxy(1,7);printf("³" );gotoxy(78,7);printf("³" );
- gotoxy(1,8);printf("³" );gotoxy(78,8);printf("³" );
- gotoxy(1,9);printf("³" );gotoxy(78,9);printf("³" );
- gotoxy(1,10);printf("³" );gotoxy(78,10);printf("³" );
- gotoxy(1,11);printf("³" );gotoxy(78,11);printf("³" );
- gotoxy(1,12);printf("³" );gotoxy(78,12);printf("³" );
- gotoxy(1,13);printf("³" );gotoxy(78,13);printf("³" );
- gotoxy(1,14);printf("³" );gotoxy(78,14);printf("³" );
- gotoxy(1,15);printf("³" );gotoxy(78,15);printf("³" );
- gotoxy(1,16);printf("³" );gotoxy(78,16);printf("³" );
- gotoxy(1,17);printf("³" );gotoxy(78,17);printf("³" );
- gotoxy(1,18);printf("³" );gotoxy(78,18);printf("³" );
- gotoxy(1,19);printf("³" );gotoxy(78,19);printf("³" );
- gotoxy(1,20);printf("³" );gotoxy(78,20);printf("³" );
- gotoxy(1,21);printf("³" );gotoxy(78,21);printf("³" );
- gotoxy(1,22);printf("³" );gotoxy(78,22);printf("³" );
- gotoxy(1,23);printf("³" );gotoxy(78,23);printf("³" );
- gotoxy(1,24);printf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
- ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
- " );
- gotoxy(5,7);printf("1.Le numero de volume" );
- gotoxy(5,8);printf("2.Le titre" );
- gotoxy(5,9);printf("3.L'auteur" );
- gotoxy(5,10);printf("4.L'editeur" );
- gotoxy(5,11);printf("5.La date" );
- gotoxy(5,12);printf("6.Quitter" );
- do
- {
- gotoxy(18,15);printf("Entrez le nø du champs ? modifier: " );
- fflush(stdin);
- menu=getche();
- }
- while (menu<49 || menu>54);
- switch(menu)
- {
- case 49:clrscr();
- printf ("\nNøde volume actuel: %d",vbibse.volu);
- printf ("\nNouveau nø: " );
- fflush(stdin);
- scanf ("%d",&volume);
- while (volume<1 || volume>15000)
- {
- clrscr();
- textcolor(RED);
- cprintf("\nAttention, le num?ro de volume doit etre un chiffre comprit 1 et 15000!" );
- textcolor(LIGHTGRAY);
- printf("\n\nVeuillez r?entrer un num?ro de volume: " );
- fflush(stdin);
- scanf("%d",&volume);
- }
- break;
- case 50:clrscr();
- fflush(stdin);
- printf ("\nTitre actuel: %s",vbibse.titr);
- printf ("\nNouveau titre: " );
- fflush(stdin);
- gets(titre);
- break;
- case 51:clrscr();
- printf ("\nAuteur actuel: %s",vbibse.aut);
- printf ("\nNouvel auteur: " );
- fflush(stdin);
- gets(auteur);
- break;
- case 52:clrscr();
- printf ("\nEditeur actuel: %s",vbibse.edit);
- printf ("\nNouvel editeur: " );
- fflush(stdin);
- gets(editeur);
- break;
- case 53:clrscr();
- printf ("\nDate actuelle: %s",vbibse.dat);
- printf ("\nNouvelle date: " );
- fflush(stdin);
- gets(date);
- break;
- }
-
- if (volume!=0)
- {
- vbibse.volu=volume;
- }
- if (titre[0]!='')
- {
- strcpy(vbibse.titr,titre);
- }
- if (auteur[0]!='')
- {
- strcpy(vbibse.aut,auteur);
- }
- if (editeur[0]!='')
- {
- strcpy(vbibse.edit,editeur);
- }
- if (date[0]!='')
- {
- strcpy(vbibse.dat,date);
- }
- fseek(ps,(posi)*sizeof(vbibse),0);
- fwrite(&vbibse,sizeof(vbibse),1,ps);
- }
- fclose(ps);
- }
- }
- else
- {
- printf("Cette fiche n'exsiste pas." );
- fflush(stdin);
- getch();
- }
- }
- else
- {
- pt=fopen("file.dat","r+b" );
- fseek(pt,(posi-1)*sizeof(vbib),0);
- fread(&vbib,sizeof(vbib),1,pt);
- if (vbib.numero==0)
- {
- clrscr();
- printf ("Cette fiche a deja ?t? supprim?e." );
- fflush(stdin);
- getch();
- }
- else
- {
- while (menu!=54)
- {
- clrscr();
- textcolor(RED);
- gotoxy(3,3);cprintf("Menu de modification:" );
- textcolor(LIGHTGRAY);
- gotoxy(1,1);printf("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
- ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
- " );
- gotoxy(1,2);printf("³" );gotoxy(78,2);printf("³" );
- gotoxy(1,3);printf("³" );gotoxy(78,3);printf("³" );
- gotoxy(1,4);printf("³" );gotoxy(78,4);printf("³" );
- gotoxy(1,5);printf("Ã" );gotoxy(78,5);printf("³" );
- gotoxy(2,5);printf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
- ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ" )
- ;
- gotoxy(1,6);printf("³" );gotoxy(78,6);printf("³" );
- gotoxy(1,7);printf("³" );gotoxy(78,7);printf("³" );
- gotoxy(1,8);printf("³" );gotoxy(78,8);printf("³" );
- gotoxy(1,9);printf("³" );gotoxy(78,9);printf("³" );
- gotoxy(1,10);printf("³" );gotoxy(78,10);printf("³" );
- gotoxy(1,11);printf("³" );gotoxy(78,11);printf("³" );
- gotoxy(1,12);printf("³" );gotoxy(78,12);printf("³" );
- gotoxy(1,13);printf("³" );gotoxy(78,13);printf("³" );
- gotoxy(1,14);printf("³" );gotoxy(78,14);printf("³" );
- gotoxy(1,15);printf("³" );gotoxy(78,15);printf("³" );
- gotoxy(1,16);printf("³" );gotoxy(78,16);printf("³" );
- gotoxy(1,17);printf("³" );gotoxy(78,17);printf("³" );
- gotoxy(1,18);printf("³" );gotoxy(78,18);printf("³" );
- gotoxy(1,19);printf("³" );gotoxy(78,19);printf("³" );
- gotoxy(1,20);printf("³" );gotoxy(78,20);printf("³" );
- gotoxy(1,21);printf("³" );gotoxy(78,21);printf("³" );
- gotoxy(1,22);printf("³" );gotoxy(78,22);printf("³" );
- gotoxy(1,23);printf("³" );gotoxy(78,23);printf("³" );
- gotoxy(1,24);printf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
- ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
- " );
- gotoxy(5,7);printf("1.Le numero de volume" );
- gotoxy(5,8);printf("2.Le titre" );
- gotoxy(5,9);printf("3.L'auteur" );
- gotoxy(5,10);printf("4.L'editeur" );
- gotoxy(5,11);printf("5.La date" );
- gotoxy(5,12);printf("6.Quitter" );
- do
- {
- gotoxy(18,15);printf("Entrez le nø du champs ? modifier: " );
- fflush(stdin);
- menu=getche();
- }
- while (menu<49 || menu>54);
- switch(menu)
- {
- case 49:clrscr();
- printf ("\nNøde volume actuel: %d",vbib.volume);
- printf ("\nNouveau nø: " );
- fflush(stdin);
- scanf ("%d",&volume);
- while (volume<1 || volume>15000)
- {
- clrscr();
- textcolor(RED);
- cprintf("\nAttention, le num?ro de volume doit etre un chiffre comprit 1 et 15000!" );
- textcolor(LIGHTGRAY);
- fflush(stdin);
- printf("\n\nVeuillez r?entrer un num?ro de volume: " );
- fflush(stdin);
- scanf("%d",&volume);
- }
- break;
- case 50:clrscr();
- printf ("\nTitre actuel: %s",vbib.titre);
- printf ("\nNouveau titre: " );
- fflush(stdin);
- gets(titre);
- break;
- case 51:clrscr();
- printf ("\nAuteur actuel: %s",vbib.auteur);
- printf ("\nNouvel auteur: " );
- fflush(stdin);
- gets(auteur);
- break;
- case 52:clrscr();
- printf ("\nEditeur actuel: %s",vbib.edition);
- printf ("\nNouvel editeur: " );
- fflush(stdin);
- gets(editeur);
- break;
- case 53:clrscr();
- printf ("\nDate actuelle: %s",vbib.date);
- printf ("\nNouvelle date: " );
- fflush(stdin);
- gets(date);
- break;
- }
- if (volume!=0)
- vbib.volume=volume;
- if (titre[0]!='')
- strcpy(vbib.titre,titre);
- if (auteur[0]!='')
- strcpy(vbib.auteur,auteur);
- if (editeur[0]!='')
- strcpy(vbib.edition,editeur);
- if (date[0]!='')
- strcpy(vbib.date,date);
- fseek(pt,(posi-1)*sizeof(vbib),0);
- fwrite(&vbib,sizeof(vbib),1,pt);
- }
- }
- fclose(pt);
- }
-
- }
-
- /*////////////////////////////////////////////////////////////////////*/
|
---------------
:sol:
|