?? hospital sys01.cpp
字號:
puts(disease);
cout<<"\t\t\tStatus: ";
puts(cond);
cout<<"\t\t\tDays admitted :"<<adays<<endl;
cout<<"\t\t\tAttending doctor: ";
puts(doctor);
cout<<"\t\t\tPresently Lying in ward "<<ward<<" bed "<<bed<<endl;
cout<<"\t\t\tBill to be paid: "<<bill<<endl;
box();
gotoxy(0,16);
cout<<"\n\t\tDo you want to see address of patient(y/n): ";
cin>>a;
if(a=='y')
{
o.open("addr.txt",ios::in|ios::out|ios::app|ios::binary);
do
{
o.read((char*)&ad,sizeof(addr));
if(n==ad.n)
ad.view();
}while(o);
o.close();
}
};
/////////////searches the given string against its field and returns search result////////
int patient::search(char str[20],int c)
{
if(c==2)
{
if(strcmp(name,str)==0)
return(1);
}
if(c==3)
{
if(strcmp(disease,str)==0)
return(1);
}
if(c==4)
{
if(strcmp(doctor,str)==0)
return(1);
}
if(c==5)
{
if(strcmp(ward,str)==0)
return(1);
}
else
return(0);
};
//////////sets doctor to a disease//////////
char* dis(char *d)
{
int w;
w=strcmp(d,"cancer");
if(w==0)
return("Dr. Tommy");
w=strcmp(d,"radioactive exposure");
if(w==0)
return("Dr. Freeman");
w=strcmp(d,"split personality");
if(w==0)
return("Dr. Rieper");
w=strcmp(d,"bullet wound");
if(w==0)
return("Dr. Payne");
w=strcmp(d,"ocd");
if(w==0)
return("Dr. Gognitti");
w=strcmp(d,"pregnancy");
if(w==0)
return("Dr. Mathers");
};
/////////////counts no. of records//////////////
int count()
{
patient p[20];
fstream o;
int i;
o.open("hospital.txt",ios::in|ios::out|ios::binary);
for(i=1;;i++)
{
o.read((char*)&p,sizeof(patient));
if(!o)
break;
}
--i;
o.close();
return(i);
};
/////////////modifys values in class 'patient'////////////
void modify(int rec)
{
fstream o;
patient p;
o.open("hospital.txt",ios::in|ios::out|ios::binary);
o.seekg(((rec-1)*sizeof(patient)),ios::beg);
o.read((char*)&p,sizeof(patient));
if(rec==p.n)
{
clrscr();
cout<<"\t\t\tOld Values are: ";
p.out1();
clrscr();
cout<<"\t\t\tEnter New Values:(press any key) "<<endl;
getch();
clrscr();
o.seekp(((rec-1)*sizeof(patient)),ios::beg);
clrscr();
p.inp1();
o.write((char*)&p,sizeof(patient));
o.seekg(0);
}
o.close();
};
/////////////deletes values in class 'patient'////////////
void del(int rec)
{
patient p;
fstream o,d;
int flag;
o.open("hospital.txt",ios::in|ios::out|ios::binary);
d.open("temp1.txt",ios::in|ios::out|ios::binary);
clrscr();
do
{
o.read((char*)&p,sizeof(patient));
if(!o)
break;
else if(rec!=p.n)
d.write((char*)&p,sizeof(patient));
else if(rec==p.n)
flag=1;
}while(o);
addrd(rec);
cout<<"\n\n\n\t\t\tRecord No. "<<rec<<" DELETED";
box();
getch();
d.seekg(0);
d.close();
o.close();
remove("hospital.txt");
rename("temp1.txt","hospital.txt");
if(flag!=1)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -