struct employee
{
char employeeid[10];//工号
char name[10]; //姓名
char sex[5]; //性别
int age; //年龄
char job[5]; //岗位
float basesalary; //基本工资
float yiliaobaoxian; //医疗保险
float gongjijin; //公积金
float totalwage; //总工资
};
struct employee emp[N];
struct employee replace;
struct employee *p=emp;
void input()
{
int c;
p=emp;
printf(" 进入职工信息输入模块 \n\n\n");
printf(" 请输入增加职工的数量: \n\n\n");
scanf("%d",&NN);
for(c=0;c<NN;c++,p++)
{
p[c].totalwage=p[c].basesalary-p[c].yiliaobaoxian-p[c].gongjijin;
printf(" 请输入第%d个职工信息:\n\n",c+1);
printf(" 请输入职工号:\n");
scanf("%s",p->employeeid);
if(strcmp(p->employeeid,"0")!=0)
{
printf(" 请输入职工姓名:\n");
scanf("%s",p->name);
printf(" 请输入职工性别: \n");
scanf("%s",p->sex);
printf(" 请输入职工年龄: \n");
scanf("%d",&p->age);
printf(" 请输入职工工作:\n");
scanf("%s",p->job);
printf(" 请输入职工基本工资:\n");
scanf("%f",&p->basesalary);
printf(" 请输入职工医疗保险:\n");
scanf("%f",&p->yiliaobaoxian);
printf(" 请输入职工公积金: \n");
scanf("%f",&p->gongjijin);
printf(" 职工信息输入完成! \n\n");
}
else
return;
}
save();
}
void load()
{
int l;
FILE *fp;
p=emp;
if((fp=fopen("emp_list","rb"))==NULL)
{
printf(" Create file error!\n");
exit(0);
}
for(l=0;l<NN;l++,p++)
{
if(fread(p,sizeof(struct employee),1,fp)!=1)
{
printf(" file read error!\n\n");
break;
}
else
continue;
}
getchar();
fclose(fp);
}