RemovePagesResult 2023 12 22 02 28 58
RemovePagesResult 2023 12 22 02 28 58
RemovePagesResult 2023 12 22 02 28 58
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<string.h>
#include<iomanip.h>
class book
char bno[6];
char book_name[50];
char author_name[20];
public:
void create_book()
cin>>bno;
gets(book_name);
gets(author_name);
cout<<"\n\n\nBook Created..";
void show_book()
{
cout<<"\nBook no. : "<<bno;
puts(book_name);
puts(author_name);
void modify_book()
gets(book_name);
gets(author_name);
char* retbno()
return bno;
void report()
{ cout<<bno<<setw(30)<<book_name<<setw(30)<<author_name<<endl;}
class student
char admno[6];
char name[20];
public:
void create_student()
clrscr();
cin>>admno;
gets(name);
token=0;
stbno[0]='/0';
void show_student()
puts(name);
if(token==1)
else
cout<<"No";
void modify_student()
char* retadmno()
return admno;
char* retstbno()
return stbno;
int rettoken()
return token;
void addtoken()
{ token=1;}
void resettoken()
{ token=0; }
strcpy(stbno,t);
void report()
{ cout<<"\t"<<admno<<setw(20)<<name<<setw(10)<<token<<endl;}
}st; //class ends here
void write_book()
char ch;
f.open("book.dat",ios::binary|ios::app);
do
clrscr();
bk.create_book();
f.write((char*)&bk,sizeof(book));
cin>>ch;
} while(ch=='y'||ch=='Y');
f.close();
void write_student()
char ch;
f.open("student.dat",ios::out|ios::app);
do
st.create_student();
f.write((char*)&st,sizeof(student));
cin>>ch;
} while(ch=='y'||ch=='Y');
f.close();
cout<<"\nBOOK DETAILS\n";
int flag=0;
f.open("book.dat",ios::in);
while(f.read((char*)&bk,sizeof(book)))
if(strcmp(bk.retbno(),n)==0)
bk.show_book();
flag=1;
f.close();
if(flag==0)
getch();
cout<<"\nSTUDENT DETAILS\n";
int flag=0;
f.open("student.dat",ios::in);
while(f.read((char*)&st,sizeof(student)))
{
if((strcmp(st.retadmno(),n)==0))
st.show_student();
flag=1;
f.close();
if(flag==0)
getch();
void modify_book()
char n[6];
int found=0;
clrscr();
cin>>n;
f.open("book.dat",ios::in|ios::out);
if(strcmp(bk.retbno(),n)==0)
bk.show_book();
bk.modify_book();
f.seekp((-1*sizeof(bk)),ios::cur);
f.write((char*)&bk,sizeof(book));
found=1;
f.close();
if(found==0)
getch();
void modify_student()
char n[6];
int found=0;
clrscr();
cin>>n;
f.open("student.dat",ios::in|ios::out);
if(strcmp(st.retadmno(),n)==0)
st.show_student();
st.modify_student();
f.seekp((-1*sizeof(st)),ios::cur);
f.write((char*)&st,sizeof(student));
found=1;
f.close();
if(found==0)
getch();
void delete_student()
char n[6];
int flag=0;
clrscr();
cout<<"\n\n\n\tDELETE STUDENT...";
cout<<"\n\nEnter The admission no. of the Student You Want To Delete : ";
cin>>n;
f.open("student.dat",ios::in|ios::binary);
fstream f2;
f2.open("Temp.dat",ios::out|ios::binary);
f.seekg(0,ios::beg);
while(f.read((char*)&st,sizeof(student)))
if(strcmp(st.retadmno(),n)!=0)
f2.write((char*)&st,sizeof(student));
else
flag=1; }
f2.close();
f.close();
remove("student.dat");
rename("Temp.dat","student.dat");
if(flag==1)
else
getch();
void delete_book()
char n[6];
clrscr();
cout<<"\n\nEnter The Book no. of the Book You Want To Delete : ";
cin>>n;
f.open("book.dat",ios::in|ios::binary);
fstream f2;
f2.open("Temp.dat",ios::out|ios::binary);
f.seekg(0,ios::beg);
while(f.read((char*)&bk,sizeof(book)))
if(strcmp(bk.retbno(),n)!=0)
f2.write((char*)&bk,sizeof(book));
}
f2.close();
f.close();
remove("book.dat");
rename("Temp.dat","book.dat");
getch();
void display_all_stud()
clrscr();
f.open("student.dat",ios::in);
if(!f)
getch();
return;
cout<<"\n\n\t\t S T U D E N T L I S T\n\n";
cout<<"------------------------------------------------------------------\n";
cout<<"------------------------------------------------------------------\n";
while(f.read((char*)&st,sizeof(student)))
st.report();
f.close();
getch();
void display_allb()
clrscr();
f.open("book.dat",ios::in);
if(!f)
getch();
return;
cout<<"\n\n\t\tBOOK LIST\n\n";
cout<<"------------------------------------------------------------------\n";
cout<<"------------------------------------------------------------------\n";
while(f.read((char*)&bk,sizeof(book)))
bk.report();
f.close();
getch();
void book_issue()
char sn[6],bn[6];
int found=0,flag=0;
clrscr();
cin>>sn;
f.open("student.dat",ios::in|ios::out|ios::binary);
f1.open("book.dat",ios::in|ios::out|ios::binary);
if(strcmp(st.retadmno(),sn)==0)
found=1;
if(st.rettoken()==0)
cin>>bn;
while(f1.read((char*)&bk,sizeof(book))&& flag==0)
if(strcmp(bk.retbno(),bn)==0)
bk.show_book();
flag=1;
st.addtoken();
st.getstbno(bk.retbno());
int pos=-1*sizeof(st);
f.seekp(pos,ios::cur);
f.write((char*)&st,sizeof(student));
if(flag==0)
else
if(found==0)
getch();
f.close();
f1.close();
void book_deposit()
char sn[6],bn[6];
int found=0,flag=0,day,fine;
clrscr();
cin>>sn;
f.open("student.dat",ios::in|ios::out|ios::binary);
f1.open("book.dat",ios::in|ios::out|ios::binary);
if(strcmp(st.retadmno(),sn)==0)
found=1;
if(st.rettoken()==1)
while(f1.read((char*)&bk,sizeof(book))&& flag==0)
{
if(strcmp(bk.retbno(),st.retstbno())==0)
bk.show_book();
flag=1;
cin>>day;
if(day>15)
fine=(day-15)*1;
st.resettoken();
int pos=-1*sizeof(st);
f.seekp(pos,ios::cur);
f.write((char*)&st,sizeof(student));
if(flag==0)
else
if(found==0)
getch();
f.close();
f1.close(); }
void intro()
cout<<"=========================================================\n";
cout<<"=========================================================\n";
getch();
void librarian_menu()
clrscr();
int ch2;
cin>>ch2;
switch(ch2)
case 1: clrscr();
write_student();break;
case 2: display_all_stud();break;
case 3:
char num[6];
clrscr();
cin>>num;
disp_spec_stud(num);
break;
case 4: modify_student();break;
case 5: delete_student();break;
case 6: clrscr();
write_book();break;
case 7: display_allb();break;
case 8: {
char num[6];
clrscr();
cin>>num;
disp_spec_book(num);
break;
case 9: modify_book();break;
librarian_menu();
void main()
char ch;
intro();
do
clrscr();
cout<<"\n\t04. EXIT";
ch=getche();
switch(ch)
case '1':clrscr();
book_issue();
break;
case '2':book_deposit();
break;
case '3':librarian_menu();
break;
case '4':exit(0);
default :cout<<"\a";
} while(ch!='4');
}
MOTIVE
GLOBALIZED USAGE.
DECREASE REDUNDANCY.
REQUIREMENTS
HARDWARE REQUIRED
SOFTWARE REQUIRED
www.cbseportal.com
SCREEN SHOTS OF
EXECUTION
MAIN MENU
CREATING STUDENT
NEW BOOK ENTRY
BOOK ISSUE
BOOK DEPOSIT
BOOK SEARCH
BIBLIOGRAPHY