hey guys...!! i really want ur help in this program..!!
its a Hospital management system program..!!
it take input from the use..it can save input in a file..display all input on to screen, but i cant find a way to delete a record/patient details from the file
PLZ help me..!!
here is the coding!!
im working on C++, visual studio 2008,
everythign is working but i want help in case 3, and case 4.!!
#include<iostream>
#include<fstream>
#include<cstring>
using namespace std;
class hospital {
char name[80];
char id[12];
char telephone[7];
int numday;
char roomnum[3];
public:
hospital(){ };
hospital(char*n,char*i, char*t, char*r, int nu)
{
strcpy_s(name,n);
strcpy_s(id,i);
strcpy_s(telephone,t);
nu=numday;
strcpy_s(roomnum,r);
;
}
friend ostream &operator<<(ostream &stream, hospital o);
friend istream &operator>>(istream &stream, hospital &o);
};
ostream &operator<<(ostream &stream, hospital o)
{
stream<<o.name<<"\n";
stream<<"-"<<o.id<<"\n";
stream<<"0213-"<<o.telephone<<"\n";
stream<<"number of Days in hospital:"<<o.numday<<"\n";
stream<<"Cost of stay: Rs."<<o.numday*2000<<"\n";
stream<<"Room Number"<<o.roomnum<<"\n";
return stream;
}
istream &operator>>(istream &stream, hospital &o)
{
cout<<"enter name: ";
stream>>o.name;
cout<<"Enter ID: ";
stream>>o.id;
cout<<" Enter telephone number :";
stream>>o.telephone;
cout<<" Allocate a Room number for the Patient :";
stream>>o.roomnum;
cout<<" Enter number of Days spent in Hospital :";
stream>>o.numday;
cout<<"\n";
return stream;
}
int main()
{
hospital a,d;
char c;
fstream hp("hospital",ios::in|ios::out|ios::app);
if(!hp){
cout<<"cant open Hospital file.\n";
return 1;
}
for(;;)
{
do{
cout<<"Welcome to NED's Hospital management"<<"\n";
cout<<"1. Enter patients details"<<"\n";
cout<<"2. Display patient details"<<"\n";
cout<<"3. Search a patient by name"<<"\n";
cout<<"4. Delete a patient record:"<<"\n";
cout<<"5.Quit"<<"\n";
cout<<"\n Enter a choice : ";
cin>>c;
}while( c<'1'||c>'5');
switch(c){
case'1':
cin>>a;
cout<<"entry is :";
cout<<a;
hp<<a;
break;
case'2':
char ch;
hp.seekg(0, ios::beg);
while(!hp.eof()){
hp.get(ch);
if(!hp.eof()) cout<<ch;
}
hp.clear();//reset eof
cout<<endl;
break;
case'3':
break;
case'5':
hp.close();
return 0;
}
}
}