void duqu()//进行文件的读取操作
{
FILE*fq;
fq=fopen("D:\\工资管理.txt","rb+");
fread(&z[0],sizeof(struct zhigong),100,fq);
fclose(fq);
}
void shanchu()
{
int a;
int i;
int j;
char k[10];
cout<<"====请根据提示执行操作====\n"<<endl;
cout<<"输入1,按照姓名执行删除操作"<<endl;
cout<<"输入2,按照工号执行删除操作"<<endl;
cin>>a;
switch(a)
{
case 1:cout<<"请输入将被删除者的姓名:";
char m[10];
cin>>m;
for(i=0;i<100;i++)
{
if(strcmp(z[i].xingming,m)==0)
j=i;
}
for(i;i<100;i++)
{
strcpy(z[i - 1].gonghao, z[i].gonghao);
strcpy(z[i - 1].xingming, z[i].xingming);
z[i - 1].gwgz = z[i].gwgz;
z[i - 1].jxgz = z[i].jxgz;
z[i - 1].grkk = z[i].grkk;
z[i - 1].sfgz = z[i].sfgz;
z[i - 1].yfgz = z[i].yfgz;
}
printf("\n=======删除成功!========\n");
break;
case 2:cout<<"请输入将被删除者的工号:";
char n[10];
cin>>n;
for(i=0;i<100;i++)
{
if(strcmp(z[i].xingming,m)==0)
j=i;
}
for(i;i<100;i++)
{
strcpy(z[i - 1].gonghao, z[i].gonghao);
strcpy(z[i - 1].xingming, z[i].xingming);
z[i - 1].gwgz = z[i].gwgz;
z[i - 1].jxgz = z[i].jxgz;
z[i - 1].grkk = z[i].grkk;
z[i - 1].sfgz = z[i].sfgz;
z[i - 1].yfgz = z[i].yfgz;
}
printf("\n=======删除成功!========\n");
break;
}
}
void xieru1()//进行文件写入操作1
{
FILE*fp;
if ((fp=fopen("D:\\工资管理.txt","wb+"))==NULL) /*创建文件并判断是否能打开*/
{
printf ("cannot open file\n");
exit(0);
}
fwrite(&z,sizeof(struct zhigong),100,fp);
fclose(fp);
}
添加回答
举报
0/150
提交
取消