Computer
Computer
h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<string.h>
#include<iomanip.h>
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..";}
void show_book()
{
cout<<"\nBook no. : "<<bno;
cout<<"\nBook Name : ";
puts(bname);
cout<<"Author Name : ";
puts(aname);
}
void modify_book()
{
cout<<"\nBook no. : "<<bno;
cout<<"\nModify Book Name : ";
gets(bname);
cout<<"\nModify Author's Name of Book :
";
gets(aname);
}
char* retbno()
{
return bno;
}
Void report()
{
cout<<bno<<setw(30)<<bname<<setw(30)<<ana
me<<endl;
}
};
//class ends hereclass student{char
admno[6];
char name[20];
char stbno[6];
int token;
public:
void create_student()
{
clrscr();
cout<<"\nNEW STUDENT ENTRY...\n";
cout<<"\nEnter The admission no. ";
cin>>admno;
cout<<"\n\nEnter The Name of The
Student ";
gets(name);
token=0;
stbno[0]='/0';
cout<<"\n\nStudent Record Created..";
}
void show_student()
{
cout<<"\nAdmission no. :
"<<admno;cout<<"\nStudent Name : ";
puts(name);
cout<<"\nNo of Book issued :
"<<token;
if(token==1)cout<<"\nBook No
"<<stbno;
}
void modify_student()
{
cout<<"\nAdmission no. : "<<admno;
cout<<"\nModify Student Name : ";
gets(name);
}
char* retadmno()
{
return admno;
}
char* retstbno()
{
return stbno;
}
int rettoken()
{
return token;
}
Voidaddtoken()
{
token=1;
}
void resettoken()
{
token=0;
}
void getstbno(char t[]){strcpy(stbno
,t);}void
report(){cout<<"\t"<<admno<<setw(20)<
<name<<setw(10)<<token<<endl;}}; //cl
ass ends herefstream fp,fp1;book
bk;student
st;//********************************
*******************************// fun
ction to write in file//*************
*************************************
**************void write_book(){char
ch;fp.open("book.dat",ios::out|ios::a
pp);do{clrscr();bk.create_book();fp.w
rite((char*)&bk,sizeof(book));cout<<"
\n\nDo you want to add more
record..(y/n?)";cin>>ch;}while(ch=='y
'||ch=='Y');fp.close();}void
write_student(){char
ch;fp.open("student.dat",ios::out|ios
::app);do{st.create_student();fp.writ
e((char*)&st,sizeof(student));cout<<"
\n\ndo you want to add more
record..(y/n?)";cin>>ch;}while(ch=='y
'||ch=='Y');fp.close();}//***********
*************************************
***************// function to read sp
ecific record from file//************
*************************************
***************void display_spb(char
n[]){cout<<"\nBOOK DETAILS\n";int
flag=0;fp.open("book.dat",ios::in);wh
ile(fp.read((char*)&bk,sizeof(book)))
{if(strcmpi(bk.retbno(),n)==0)