#include #include #include #include using namespace std; int ch; void entry_book(); void issue_book(); void return_book(); void search(); void search_book(); char *tym(); class book { public: char b_name[50],b_pub[20],b_pur[12]; long int b_no; public: friend istream &operator >> (istream &in,book &temp); friend ostream &operator << (ostream &out,book &temp); friend ofstream &operator << (ofstream &bookout,book &temp); friend ifstream &operator >> (ifstream &bookin,book &temp); }var; class library:public book { public: char *i_dat,*r_dat,stud_name[20],clas[10]; long int b_no; public: friend ostream &operator<<(ostream &out,library & temp); friend ofstream &operator<<(ofstream &libout,library &temp); friend ifstream &operator>>(ifstream &libin,library &temp); }var2; char *tym() { time_t rawtime; struct tm * timeinfo; time ( &rawtime ); timeinfo = localtime ( &rawtime ); return ( asctime (timeinfo) ); } void entry_book() { cout<<"\nEnter Book No:"; cin>>var.b_no; cout<<"\nEnter Book name:"; cin>>var.b_name; cout<<"\nPub Name:"; cin>>var.b_pub; cout<<"\nPurchase date:"; cin>>var.b_pur; ofstream book_file; book_file.open ("book.txt"); book_file<>temp_no; ifstream book_file2; ofstream lib_file; book_file2.open("book.txt"); book_file2>>var; while(!book_file2.eof()) { if(temp_no==var.b_no) { var2.i_dat=tym(); cout<<"\nEnter Student Name:"; cin>>var2.stud_name; cout<<"\nEnter Class:"; cin>>var2.clas; lib_file.open("library.txt"); lib_file<>var; } book_file2.close(); } void return_book() { int temp_no,temp_ptr=0; char chr[10],chr1[10]; //string r_date; cout<<"\nEnter the Book Number:"; cin>>temp_no; ifstream lib_file2; ofstream lib_file3; lib_file2.open("library.txt"); lib_file2>>var2; lib_file2.seekg(0); while(!lib_file2.eof()) { if(temp_no==var2.b_no) { var2.r_dat=tym(); //temp_ptr=lib_file2.tellg(); lib_file2.get(chr[0]); while(strcmp(chr,"-")!=0) temp_ptr++; lib_file3.seekp(temp_ptr); lib_file3<<*var2.r_dat; temp_ptr+=2; lib_file3<<" R \n"; } } } void search_book() { int temp_no; cout<<"\nEnter the Book Number:"; cin>>temp_no; ifstream book_file3; book_file3.open("book.txt"); book_file3>>var; while(!book_file3.eof()) { if(temp_no==var.b_no) { cout<<"\nBook No:"<>ch; switch(ch) { case 1:entry_book(); case 2:issue_book(); case 3:return_book(); case 4:search_book(); default:cout<<"\n Wrong choice.only 1-4 is valid."; } }