deletebook.cpp

来自「图书馆管理系统 包括界面、书籍管理、会员管理等内容」· C++ 代码 · 共 52 行

CPP
52
字号
/*******Function to Delete Book******/
 # include"liba.h"

 void deletebook()
 {
   struct book B;
   int i,j,k;

   FILE *fb,*tt;
   window(1,1,80,2);
   textbackground(LIGHTGRAY);
   clrscr();
   gotoxy(30,1);
   textcolor(YELLOW);
   cprintf("Delete Book");
   window(1,2,80,25);
   textcolor(WHITE); 
   textbackground(BLUE);
   clrscr();
   fb=fopen("E:\\cpp\\book.dat","a+");
   if(( tt=fopen("temp2.dat","w"))==NULL)
    {
       printf("unable to open the file");
       exit(1);
    }
  textcolor(WHITE);
  gotoxy(5,1); cprintf("Enter Book id::");
  gotoxy(9,2); cprintf("/");
  gotoxy(13,2); cprintf("/");
  gotoxy(5,2); 
  scanf("%d",&i);
  gotoxy(10,2); 
  scanf("%d",&j);
  gotoxy(14,2);
  scanf("%d",&k);
  rewind(fb);
  while( fread(&B,sizeof(B),1,fb)==1 )
  {
   if(i==B.b.gno&&j==B.b.bno&&k==B.b.no){}
     else
      {fwrite(&B,sizeof(B),1,tt);}
  }

  fclose(tt); 
  fclose(fb);
  remove("book.dat");
  rename("temp2.dat","book.dat");

  printf("\n\t Book deleted...\npress any key to return...");
  getch();
 }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?