class book
{char bno[6];char bname[50];char aname[20];
public:void create_book(){cout<<"\nNEW BOOK ENTRY...\n";cout<<"\nEnter The book no.";cin>>bno;cout<<"\n\nEnter The Name of The Book ";gets(bname);cout<<"\n\nEnter The Author's Name ";gets(aname);cout<<"\n\n\nBook Created..";}

//***************************************************************
// function to modify record of file
//****************************************************************

void modify_book()
{char n[6];int found=0;clrscr();cout<<"\n\n\tMODIFY BOOK REOCORD.... ";cout<<"\n\n\tEnter The book no. of The book";cin>>n;fp.open("book.dat",ios::in|ios::out);while(fp.read((char*)&bk,sizeof(book)) && found==0){if(strcmpi(bk.retbno(),n)==0){bk.show_book();cout<<"\nEnter The New Details of book"<<endl;bk.modify_book();int pos=-1*sizeof(bk);fp.seekp(pos,ios::cur);fp.write((char*)&bk,sizeof(book));cout<<"\n\n\t Record Updated";found=1;}}

fp.close();if(found==0)cout<<"\n\n Record Not Found ";getch();
}

void modify_student()
{char n[6];int found=0;clrscr();cout<<"\n\n\tMODIFY STUDENT RECORD... ";cout<<"\n\n\tEnter The admission no. of The student";cin>>n;fp.open("student.dat",ios::in|ios::out);while(fp.read((char*)&st,sizeof(student)) && found==0){if(strcmpi(st.retadmno(),n)==0){st.show_student();cout<<"\nEnter The New Details of student"<<endl;st.modify_student();int pos=-1*sizeof(st);fp.seekp(pos,ios::cur);fp.write((char*)&st,sizeof(student));cout<<"\n\n\t Record Updated";found=1;}}fp.close();if(found==0)cout<<"\n\n Record Not Found ";getch();
}

//***************************************************************
// function to delete record of file
//****************************************************************

void delete_book()
{char n[6];clrscr();cout<<"\n\n\n\tDELETE BOOK ...";cout<<"\n\nEnter The Book no. of the Book You Want To Delete : ";cin>>n;fp.open("book.dat",ios::in|ios::out);fstream fp2;fp2.open("Temp.dat",ios::out);fp.seekg(0,ios::beg);while(fp.read((char*)&bk,sizeof(book))){if(strcmpi(bk.retbno(),n)!=0) {fp2.write((char*)&bk,sizeof(book));}}fp2.close();fp.close();remove("book.dat");rename("Temp.dat","book.dat");cout<<"\n\n\tRecord Deleted ..";getch();
}

//***************************************************************
// function to display all students list
//****************************************************************

void display_alls()
{clrscr();fp.open("student.dat",ios::in);if(!fp){cout<<"ERROR!!! FILE COULD NOT BE OPEN ";getch();return;}

void book_issue()
{char sn[6],bn[6];int found=0,flag=0;clrscr();cout<<"\n\nBOOK ISSUE ...";cout<<"\n\n\tEnter The student's admission no.";cin>>sn;fp.open("student.dat",ios::in|ios::out);fp1.open("book.dat",ios::in|ios::out);while(fp.read((char*)&st,sizeof(student)) && found==0){if(strcmpi(st.retadmno(),sn)==0){found=1;if(st.rettoken()==0){cout<<"\n\n\tEnter the book no. ";cin>>bn;while(fp1.read((char*)&bk,sizeof(book))&& flag==0){if(strcmpi(bk.retbno(),bn)==0){bk.show_book();flag=1;st.addtoken();st.getstbno(bk.retbno());int pos=-1*sizeof(st);fp.seekp(pos,ios::cur);fp.write((char*)&st,sizeof(student));cout<<"\n\n\t Book issued successfully\n\nPlease Note: Write current datein backside of book and submit within 15 days fine Rs. 1 for each day after 15 days period";}}if(flag==0)cout<<"Book no does not exist";}elsecout<<"You have not returned the last book ";

}}if(found==0)cout<<"Student record not exist...";getch();fp.close();fp1.close();
}