} }while(1);
return 0; }
void input() //录入函数 {
int i=0; char ch;
FILE *fp; //定义FLIe文件操作指针
if((fp=fopen(\职工考勤信息管理.txt\
if((fp=fopen(\职工考勤信息管理.txt\ {
printf(\不能建立文件!\\n\ exit(0); }
printf(\ 输入职工考勤信息 \\n\\n\ do {
printf(\ 输入格式:职工号\\t姓名\\t顺序数\\t上班时间\\t下班时间\\n\ printf(\考勤信息录入:\
scanf(\ fwrite(&fl[i],sizeof(struct worker),1,fp); //将结构体数组内容内容写到文件中
printf(\按回车键继续输入,按N停止输入:\\n\ printf(\ getchar(); ch=getch(); i++;
}while(ch!='n'&&ch!='N'); fclose(fp); n=i;
system(\}
void display() //显示函数 {
int i; char ch; FILE *fp;
if((fp=fopen(\职工考勤信息管理.txt\ {
printf(\不能打开文件!\\n\
exit(1);
} fseek(fp,0,2); //将文件指针移到文件尾 n=ftell(fp)/sizeof(struct worker); do {
printf(\
printf(\ 考勤信息 \\n\ printf(\ \\n\\n\
printf(\职工号\\t姓名\\t顺序数\\t上班时间\\t下班时间\\n\ rewind(fp); for(i=0;i printf(\ } printf(\ 按任意键返回主菜单\\n\\n\\t\\t \ ch=getch(); }while(!ch); fclose(fp); system(\} void search() //查找函数 { int x,k=0,i; char z[20],s[N][20],ch; FILE *fp; if((fp=fopen(\职工考勤信息管理.txt\ { printf(\不能打开文件!\\n\ exit(1); } fseek(fp,0,2); n=ftell(fp)/sizeof(struct worker); do { haha: printf(\ 考勤信息查询 \\n\ printf(\按职工号查询\\n\ printf(\按姓名查询\\n\ printf(\按上班时间查询\\n\ printf(\按下班时间查询\\n\ printf(\返回主菜单\\n\ printf(\退出并保存\\n\\n\ printf(\ 选择功能选项(输入功能前的数字) \\n\\n\ printf(\ scanf(\ getchar(); system(\ for(i=0;i case 1: strcpy(s[i],fl[i].no);break; case 2: strcpy(s[i],fl[i].name);break; case 3: strcpy(s[i],fl[i].go);break; case 4: strcpy(s[i],fl[i].back);break; case 5: goto ap; case 6: exit(0); default: goto haha; } } do { printf(\请输入查询信息: \ gets(z); for(i=0;i printf(\ ------------------------------------------------------------------------\\n\ printf(\职工号\\t姓名\\t顺序数\\t上班时间\\t下班时间\\n\ printf(\ printf(\ ------------------------------------------------------------------------\\n\ } if(k==0) { printf(\没有此职工信息!!!\ } printf(\按回车键继续查询,按N停止查询:\ ch=getch(); }while(ch!='N'&&ch!='n'); system(\ }while(1); fclose(fp); ap : system(\} void del() //删除函数 { char st[20],m[20]; int i,j,l; FILE *fp; if ((fp=fopen(\职工考勤信息管理.txt\ { printf(\不能创建文件\\n\ exit(0); } fseek(fp,0,2); n=ftell(fp)/sizeof(struct worker); fclose(fp); fp=fopen(\职工考勤信息管理.txt\ printf(\ printf(\ 考勤信息删除\\n\ printf(\ printf(\按职工号删除\\n\ printf(\按姓名删除\\n\ printf(\按上班时间删除\\n\ printf(\按下班时间删除\\n\ printf(\ 选择功能选项(输入功能前的数字) \\n\\n\ printf(\ scanf(\ getchar(); //存放回车符 printf(\请输入删除职工的具体条件:\ scanf(\ //输入的具体条件存入m数组 getchar(); system(\ printf(\ \\n\ printf(\ 职工信息删除成功\\n\ printf(\ \\n\ printf(\其他职工信息有:\\n\ printf(\ \\n\ printf(\ printf(\职工号\\t姓名\\t顺序数\\t上班时间\\t下班时间\\n \ for(i=0;i switch(l) { case 1: strcpy(st,fl[i].no);break; case 2: strcpy(st,fl[i].name);break; case 3: strcpy(st,fl[i].go);break; case 4: strcpy(st,fl[i].back);break; default:printf(\ 选择错误 \\n\ } if(strcmp(m,st)!=0) //查找到要删除的信息 { j=i; fwrite(&fl[j],sizeof(struct worker),1,fp); //不要删除的信息写回文件 printf(\能帮助观察是否已经删掉了要删的信息 } } printf(\ fclose(fp); getchar(); //存放回车符 system(\ }