#include <stdio.h>
#include<conio.h>
#include<string.h>
struct library {char name[20]; char newspap[15]; char magazine[15]; float price; int circula;} l1;
void input (FILE*);
void edit (FILE*);
void app (FILE*);
main()
{
char c;
FILE*nf;
while (1)
{clrscr();
puts("1-®ўл© д ©«");
puts("2-Їа®б¬®ва д ©« ");
puts("3-¤®Ў ў«ҐЁҐ ў д ©«");
puts("4-ЇҐз вм");
puts("0-ўл室");
c=getch();
switch(c)
{case '1':input(nf); break;
case '2':edit(nf); break;
case '3': app(nf); break;
case '0': return 0;
defaults: puts("ҐўҐал© аҐ¦Ё¬");
}
}
}
/////////////////////////////
////////////////////////////////////////////////////////
/////////////////////////////////////
void input(FILE*nf)
{ char ch;
nf=fopen("file1.dat","wb");
clrscr();
printf("\n ‚ў®¤ ¤ ле ЎЁЎ«Ё®вҐЄЁ\n");
do
{printf("\n §ў ЁҐ:");
scanf("%s", l1.name);
printf("\n Ј §Ґв (¤ Ё«Ё Ґв):");
scanf("&s", l1.newspap);
printf("\n ¦га «(¤ Ё«Ё Ґв):");
scanf( "&s", l1.magazine);
printf("\n жҐ :");
scanf("&f", l1.price);
printf( "\n Є®««ЁзҐбвў® ўлЇгбЄ®ў ў Ј®¤:");
scanf("&d",l1.circula);
fwrite(&l1, sizeof(l1),1,nf);
printf("\n § Є®зЁвм? y/n");
ch=getch();
}
while(ch !='y');
fclose(nf);
}
////////////////////////////////////////////////////////
////////////////////////////
///////////////////
////////////////
void edit (FILE*nf)
{ int i;
clrscr();
nf=fopen("file1.dat","rb");
i=1;
fread(&l1,sizeof(l1),1,nf);
while(!feof(nf))
{printf("\n %3s §ў %10s Ј § %10s ¦га %10f жҐ %3d вЁа ¦",i,l1.name, l1.newspap,l1.magazine, l1.price, l1.circula);
fread(&l1, sizeof(l1),1,nf);
i++;
}
getch();
}
///////////////////////////////////////////////////////////
/////////////////////
/////////////
/////
void app(FILE*nf)
{ char ch;
nf=fopen("file1.dat","ab");
clrscr();
printf("ўў®¤ ¤ ле ЎЁЎ«Ё®вҐЄЁ\n");
do
{printf("\n §ў ЁҐ:");
scanf("%s",l1.name);
printf("Ј §Ґв (¤ Ё«Ё Ґв):");
scanf("%s", l1.newspap);
printf("¦га «(¤ Ё«Ё Ґв):");
scanf("%s", l1.magazine);
printf("жҐ :");
scanf("%f", l1.price);
printf("Є®««ЁзҐбвў® ўлЇгбЄ®ў ў Ј®¤:");
scanf("%d", l1.circula);
fwrite(&l1,sizeof(l1),1,nf);
printf("§ Є®зЁвм y/n");
ch=getch();
}
while (ch != 'y');
fclose(nf);
}