#include<iostream.h> #include<conio.h> #include<fstream.h> #include<stdio.h> #include<string.h> #include<process.h> class employee { int eid; char ename[20]; char empaddr[30]; char empdesig[20]; float sal; public: void getdata(); void putdata(); int return_id() { return eid; } }s; ifstream fin; ofstream fout; void employee::getdata() { cout<<"\n Enter Employee ID : ";cin>>eid; cout<<"\nEnter Employee Name : ";gets(ename); cout<<"\n Enter Address : ";gets(empaddr); cout<<"\n Enter Designation : ";gets(empdesig); cout<<"\n Enter Salary : ";cin>>sal; } void employee::putdata() { cout<<"\n----EMPLOYEE DETAILS----"; cout<<"\n Employee ID = "<<eid; cout<<"\nEmployee Name = "<<ename; cout<<"\n Address = "<<empaddr; cout<<"\n Deisgnation = "<<empdesig; cout<<"\n Salary = "<<sal; } void create() { int n; fout.open("record.dat",ios::out|ios::binary); cout<<"\nEnter Number of Employees" <<"to be Added : "; cin>>n; for(int i=0;i<n;i++) { cout<<"\nEnter Details of Employee "<<i+1; cout<<"\n-----------------------------"; s.getdata(); fout.write((char *)&s,sizeof(s)); cout<<"\nDetails are Added to File Successfully"; } fout.close(); } void append() { fout.open("record.dat",ios::app|ios::binary); cout<<"\n---Enter the Details to be Appended---"; s.getdata(); fout.write((char *)&s,sizeof(s)); fout.close(); } void display() { fin.open("record.dat",ios::in|ios::binary); while(fin.read((char *)&s,sizeof(employee))) if(!fin.eof()) s.putdata(); fin.close(); } void modify() { int flag=0; fstream f; f.open("record.dat",ios::in|ios::out|ios::binary); long pos; int g; employee s; cout<<"\nEnter the ID to modify : ";cin>>g; while(f) { pos=f.tellg(); f.read((char *)&s,sizeof(s)); if(s.return_id()==g) { s.getdata(); flag=1; f.seekg(pos); f.write((char *)&s,sizeof(s)); } } if(flag==0) { cout<<"\nSorry ID not found"; } f.close(); } void main() { int c; do { clrscr(); cout<<"\n----MENU----"; cout<<"\n1.Create\n2.Display\n3.Append" <<"\n4.Modify\n5.Exit"; cout<<"\nEnter your choice : ";cin>>c; switch(c) { case 1: create(); break; case 2: display(); break; case 3: append(); cout<<"\nNew Details are added"; break; case 4: modify(); break; case 5: exit(0); default: cout<<"\nWrong choice!!!"; } cout<<"\nPress any key to continue"; getch(); }while(1); }
CPP Menu driven program for maintaining EMPLOYEE details
Subscribe to:
Post Comments (Atom)
Baccarat - How to play, strategy, strategies and play
ReplyDeleteYou want the game to be played in 3-5 hands, and you have the option to play against the dealer. That's what happens in Baccarat. The game is quite simple. You 바카라 사이트 주소 need a