武汉工程大学-网络工程-工资管理软件.doc_第1页
武汉工程大学-网络工程-工资管理软件.doc_第2页
武汉工程大学-网络工程-工资管理软件.doc_第3页
武汉工程大学-网络工程-工资管理软件.doc_第4页
武汉工程大学-网络工程-工资管理软件.doc_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

#include #include #include #include using namespace std; struct EMPchar name25;float salary;int deleted;void main()EMP e;strcpy(,NULL);e.salary = 0;e.deleted = 0;while(1)char c;cout;cin.get(c);if(c = n)coutName: ;;cine.salary;e.deleted = 0;else if(c = s)if(strcmp(,NULL) = 0)coutnEnter employee data before trying to save;continue;ofstream file;file.open(EMP.DAT,ios:app|ios:binary);if(! file)coutnFailed to save data;continue;file.write(char *)&e,sizeof(e);file.close();coutnFile saved;else if(c = l)ifstream infile ;infile.open (EMP.DAT,ios:binary);if(! infile)coutnFailed to read file;continue ;long curpos,length;curpos = infile.tellg();infile.seekg(0L,ios:end);length = infile.tellg();infile.seekg(0L,ios:beg);long num_recs = length / sizeof(e);for(long l = 0;lnum_recs;l+)infile.read(char *)&e,sizeof(e);coutnName: ;coutnSalary: e.salary;infile.close();coutnntRecords: num_recs;else if(c = h)coutnn - Newns - Savenl - Listnq - Quit;else if(c = q)break;else if(c = f)ifstream infile1;infile1.open(EMP.DAT,ios:binary);if(! infile1)coutFailed to open file;continue;coutEnter employee name: f;long curpos,length;curpos = infile1.tellg();infile1.seekg(0L,ios:end);length = infile1.tellg();infile1.seekg(0L,ios:beg);long num_recs = length / sizeof(e);int found = 0;for(long l = 0;lnum_recs;l+)infile1.read(char *)&e,sizeof(e);if(strcmp( ,f) = 0)coutnName: ;coutnSalary: e.salary ;found = 1;if(found = 0)coutRecord not found ;infile1.close ();else if(c = d)ifstream infile2;ofstream temp_file;infile2.open (EMP.DAT,ios:binary);if(! infile2)coutFailed to load data;continue ;temp_file.open(EMP_TEMP.DAT,ios:binary);if(! temp_file)coutFailed to creat temp file;continue;coutf;long curpos,length;curpos = infile2.tellg();infile2.seekg(0L,ios:end);length = infile2.tellg();infile2.seekg(0L,ios:beg);long num_recs = length / sizeof(e);int found = 0;for(long l = 0;lnum_recs;l+)infile2.read(char *)&e,sizeof(e);if(strcmp( ,f) = 0)e.deleted = 1;found = 1;temp_file.write (char *)&e,sizeof(e);infile2.close();temp_file.close ();if(found = 0)coutRecord not found ;continue ;ofstream outfile(EMP.DAT,ios:binary);ifstream infile3(EMP_TEMP.DAT,ios:binary);curpos = infile3.tellg ();infile3.seekg(0L,ios:end);length = infile3.tellg();infile3.seekg(0L,ios:beg);num_recs = length / sizeof(e);for(l = 0;lnum_recs;l+)infile3.read(char *)&e,sizeof(e);if(e.deleted = 0)outfile.write (char *)&e,sizeof(e);infile3.close ();outfile.close ();coutRecord deleted;else if(c = e)ifstream infile4;infile4.open (EMP.DAT,ios:binary);if(! infile4)coutFailed to open file;continue ;coutf;long curpos,length;curpos = infile4.tellg();infile4.seekg(0L,ios:end);length = infile4.tellg();infile4.seekg(0L,ios:beg);long num_recs = length / sizeof(e);int found = 0;char new_name25;float new_sal;EMP new_emp;long write_at;for(long l = 0;lnum_recs;l+)infile4.read(char *)&e,sizeof(e);if(strcmp( ,f) = 0)coutnew_name;coutnew_sal;strcpy(new_,new_name);new_emp.salary = new_sal;new_emp.deleted = 0;found = 1;write_at = l;break;infile4.close ();if(found = 1)write_at = write_at *sizeof(new_emp);fstream file (EMP.DAT,ios:binary|ios:in|ios:out);if(! file)coutEditing failed;continue;fi

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论