请问这个C语言错误error C2440: '=' : cannot convert from 'void' to 'int'怎么改
#include<stdio.h>#include<string.h>structsalary_list{charname[50];charnum[20];intage;...
#include<stdio.h>
#include<string.h>
struct salary_list
{
char name[50];
char num[20];
int age;
char career[20];
int month;
double base;
double bonus;
double insurance;
double total;
};
int Count=0;
void addnew_salary(struct salary_list salary[]);
void update_salary(struct salary_list salary[]);
void delete_salary(struct salary_list salary[]);
void search_salary(struct salary_list salary[],char*name);
int sort_salary(struct salary_list salary[]);
int load();
void search_name();
void search_num();
int main(void)
{
int choice;
char name[50];
struct salary_list salary[50];
{
FILE*fp;
if(fp=fopen("工资信息.txt","r"))
{
while (!feof(fp))
{
fscanf(fp,"%s %s %d %s %d %lf %lf %lf %lf",
salary[Count].name,
salary[Count].num,
&salary[Count].age,
salary[Count].career,
&salary[Count].month,
&salary[Count].base,
&salary[Count].bonus,
&salary[Count].insurance,
&salary[Count].total);
Count++;
}
fclose(fp);
}
}
do
{
printf("工资管理系统:1:新增 2:修改 3:删除 4:查询 5:排序 0:退出\n");
printf("请选择功能:");
scanf("%d",&choice);
switch(choice)
{
case 1:
addnew_salary(salary);
break;
case 2:
update_salary(salary);
break;
case 3:
delete_salary(salary);
break;
case 4:
sort_salary(salary);
break;
case 5:
search_salary(salary,name);
break;
case 0:
break;
}
}
while (choice!=0);
int n;
FILE*fp;
if(fp=fopen("f1.txt","w"))
{
while(n<=Count)
{
fprintf(fp,"%s %s %d %s %d %lf %lf %lf %lf",
salary[n].name,
salary[n].num,
salary[n].age,
salary[n].career,
salary[n].month,
salary[n].base,
salary[n].bonus,
salary[n].insurance,
salary[n].total);
n++;
}
fclose(fp);
}
printf("谢谢使用此功能!\n");
return 0;
}
void delete_salary(struct salary_list salary[])
{
int i,index;
char name[50];
index=search_salary(salary,name);
if(index<0)
return;
for(i=index;i<Count-1;i++)
{
salary[i]=salary[i+1];
Count--;
}
printf("删除成功!\n");
}
在index=search_salary(salary,name);这里错 展开
#include<string.h>
struct salary_list
{
char name[50];
char num[20];
int age;
char career[20];
int month;
double base;
double bonus;
double insurance;
double total;
};
int Count=0;
void addnew_salary(struct salary_list salary[]);
void update_salary(struct salary_list salary[]);
void delete_salary(struct salary_list salary[]);
void search_salary(struct salary_list salary[],char*name);
int sort_salary(struct salary_list salary[]);
int load();
void search_name();
void search_num();
int main(void)
{
int choice;
char name[50];
struct salary_list salary[50];
{
FILE*fp;
if(fp=fopen("工资信息.txt","r"))
{
while (!feof(fp))
{
fscanf(fp,"%s %s %d %s %d %lf %lf %lf %lf",
salary[Count].name,
salary[Count].num,
&salary[Count].age,
salary[Count].career,
&salary[Count].month,
&salary[Count].base,
&salary[Count].bonus,
&salary[Count].insurance,
&salary[Count].total);
Count++;
}
fclose(fp);
}
}
do
{
printf("工资管理系统:1:新增 2:修改 3:删除 4:查询 5:排序 0:退出\n");
printf("请选择功能:");
scanf("%d",&choice);
switch(choice)
{
case 1:
addnew_salary(salary);
break;
case 2:
update_salary(salary);
break;
case 3:
delete_salary(salary);
break;
case 4:
sort_salary(salary);
break;
case 5:
search_salary(salary,name);
break;
case 0:
break;
}
}
while (choice!=0);
int n;
FILE*fp;
if(fp=fopen("f1.txt","w"))
{
while(n<=Count)
{
fprintf(fp,"%s %s %d %s %d %lf %lf %lf %lf",
salary[n].name,
salary[n].num,
salary[n].age,
salary[n].career,
salary[n].month,
salary[n].base,
salary[n].bonus,
salary[n].insurance,
salary[n].total);
n++;
}
fclose(fp);
}
printf("谢谢使用此功能!\n");
return 0;
}
void delete_salary(struct salary_list salary[])
{
int i,index;
char name[50];
index=search_salary(salary,name);
if(index<0)
return;
for(i=index;i<Count-1;i++)
{
salary[i]=salary[i+1];
Count--;
}
printf("删除成功!\n");
}
在index=search_salary(salary,name);这里错 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询