Sie sind auf Seite 1von 8

#include<iostream.h> #include<conio.h> #include<string.h> #include<stdio.h> #include<fstream.h> #include<process.h> #include<time.

h> class register { char m_name[50]; //mother name char f_name[50]; //father name char p_birth[50]; //place of birth char now[50]; //time of registration char gender; char h_name[50];//hospital name char h_city[50];//hospital city char address1[100];//adress of child char city[50],state[50]; int p_code;//pin code char reg_no[50]; public: void new() { cout<<"\nenter mother's name:\n"; gets(m_name);

cout"<<enter father's name:\n"; gets(f_name); cout<<"enter place of birth:\n"; gets(p_birth); cout<<"enter the gender of the child:\n" cin>>gender; cin<<"enter your address(house number,sector,appartment name)\n"; gets(address1); cout<<"enter your city\n"; gets(city); cout<<"enter your state\n"; gets(state); cout<<"enter your area pincode\n"; cin>>p_code; cout<<"enter hospital name\n"; gets(h_name); cout<<"enter city in which the hospital is located\n"; gets(h_city); } void display() { cout<<"mother's name : "<<m_name<<"\n"; cout<<"father's name : "<<f_name<<"\n"; cout<<"place of birth : "<<p_birth<<"\n"; cout<<"gender : "<<gender<<"\n";

cout<<"house address : "<<address1<<","<<city<<","<<state<<","<<p_code<<"\n"; cout<<"hospital address: "<<h_name<<","<<h_city<<"\n"; } void generate_time() {

} void modify() { char nm_name; char nf_name; char np_birth; char n_gender; cout<<"enter new data\n\n"; cout<<"enter mother's name\n"; gets(nm_name); cout<<"enter father's name\n"; gets(nf_name); cout<<"enter place of birth\n"; gets(np_birth); cout<<"enter child's gender\n"; cin>>n_gender; strcpy(m_name,nm_name); strcpy(f_name,nf_name); strcpy(p_birth,np_birth); //adress hospital name hostitla addreass

strcpy(gender,n_gender); } int retno { return reg_no; }

void main() { register r,r1,r2,r3; char x; char rno[50],rno2[50],rno3[50]; int a,found=1,flag=1,flag2=1; long pos; clrscr(); cout<<"\t\tWELCOME TO MCD BIRTH CERTIFICATE GENERATOR\n\n"; l: cout<<"\t\t1.Generate a new birth certificate\n"; cout<<"\t\t2.modify an existing certificate\n"; cout<<"\t\t3.delete an existing certificate\n"; cout<<"\t\t4.show all records\n"; cout<<"\t\t5.search for a record\n"; cout<<"\t\t6.exit\n"; cin>>a; //char* dt = ctime(&now); // time_t now = time(0);

fstream fil("registrations.dat";ios::in|ios::out|ios::binary|ios::app); fil.close(); switch(a) { case 1: { r.generate_time(); fil.open("registrations.dat";ios::in|ios::out|ios::binary|ios::app); do { r.new(); fil.write((char*)&r,sizeof(r)); cout<<"do you want to enter more data\n"; }while(x=='y'); fil.close(); goto l; } case 2: { cout<<"enter a registration number to be modified\n"; cin>>rno; fil.open("regiser.dat";ios::in|ios::out|ios::binary|ios::app); while(!register.eof()) { pos=fil.tellg();

fil.read((char*)&r1,sizeof(r1)); if(strcmp(r1.retno(),rno)==0) { r1.modify(); fil.seekg(pos); fil.write((char*)&s,sizeof(s)); cout<<"changed details are "<<endl; r1.output(); flag=0; } } if(flag==1) cout<<"record not found\n"; fil.close(); goto l; }

case 3: { fil.open("regiser.dat";ios::in|ios::out|ios::binary|ios::app); fstream q("temp.dat",ios::in|ios::out|ios::binary|ios::app); cout<<"enter a roll numnber to be deleted"<<endl; cin>>rno2; while(!fil.eof()) {

fil.read((char*)&r2,sizeof(r2)); if(strcmp(r2.retno(),rno2)!=0) q.write((char*)&r2,sizeof(r2)); else found=0; } if(found==1) cout<<"record no found!!"<<endl; fil.close(); b.close(); remove("register.dat"); rename("temp.dat","register.dat"); goto l; } case 4: { fil.open("register.dat",ios::in|ios::out|ios::binary|ios::app); while(!fil.eof()) { r3.display(); fil.write((char*)&r3,sizeofr3)); } fil.close(); goto l; }

case 5: { cout<<"enter a registration number you want to search\n"; gets(rno3); fil.open("register.dat",ios::in|ios::out|ios::binary|ios::app); while(!fil.eof()) { if(strcmp(r4.retno(),rno3)==0) r4.display(); flag2=0; } if(flag2==1) cout<<"record not found\n"; fil.close(); goto l; } case 6: exit(0); } getch(); }

Das könnte Ihnen auch gefallen