有5处不能修改的错误,1个警告,在线等
# include <stdio.h># include <stdlib.h>
# include <string.h>
#define M 60
#define N 10
struct student
{
int NO;
char name[20];
int num;
float money;
char from[20];};
void xiugai()
{int i;
char ch;
FILE *fp;
struct student *read(),*p;
p=read();
printf("请输入你想查看的商品:\n");
scanf("%d",&i);
while(i!=0)
{if((fp=fopen("student.txt","wb"))==NULL)
{printf("Can't open this file\n");
return;
}
i--;
printf("NO\tname\tnumber\tmoney\tfrom\t\n");
printf("%d\t%s\t%d\t%d\t%s\t",(p+i)->name,(p+i)->num,(p+i)->money,(p+i)->from);
printf("have a problem(y or n):\n");
scanf("%c",&ch);
if(ch='y')
{scanf("%d\t%s\t%d\t%d\t%s\t",&(p+i)->name,&(p+i)->num,&(p+i)->money,&(p+i)->from);
fwrite(p+i,sizeof(p),1,fp);
fclose(fp);
}
}
scanf("%d",&i);
}
void sale()//销售员销售情况查询
{int i,j,m,n;
struct student pd[M],*read(),*p;
p=read();
for(m=1;m<11;m++)
for(j=0;j<M;j++)
{double sum1=(p+j)->money,sum2,sum3;
sum3=sum1;
sum2=sum1;
scanf("%d,%d",&n,&i);
while((i>0&&i<61)&&(n>-1&&n<11))
{i--;
if(((p+j)->NO=(p+i)->NO)&&m=n)
{sum1=sum1+(p+i)->money;
sum2=sum2+(p+i)->money;
sum3=sum3+(p+i)->money;
printf("%d号销售员的第%d种商品总额为:%f",m,j,sum1);
printf("%d号销售员销售总额为:%f",m,sum2);
printf("第%d种商品总额为:%f",m,sum3);
}
else if(m=n)
{sum2=sum2+(p+i)->money;
printf("%d号销售员销售总额为:%f",m,sum2);
}
else if((p+j)->NO=(p+i)->NO)
{sum3=sum3+(p+i)->money;
printf("第%d种商品总额为:%f",m,sum3);}
scanf("%d,%d",&n,&i);}
}
void search_mey()//查询1
{int i;
float j;
struct student pd[M],*read(),*p;
p=read();
printf("请根据你要查询的商品的价格输入:\n");
scanf("%f",&j);
for(i=0;i<M;i++,p++)
{if(j-p->money=0)
{printf("NO\tname\tnumber\tmoney\tfrom\t\n");
printf("%d\t%s\t%d\t%d\t%s\t",p->name,p->num,p->money,p->from);}
else printf("我们暂时没有该商品\n");}
}
void search_num()//查询2
{
int i,j;
struct student *read(),*p;
p=read();
printf("请根据你要查询的商品的数量输入:\n");
scanf("%d",&j);
for(i=0;i<M;i++,p++)
{if(j=p->num)
{printf("NO\tname\tnumber\tmoney\tfrom\t\n");
printf("%d\t%s\t%d\t%d\t%s\t",p->name,p->num,p->money,p->from);}
else printf("我们暂时没有该商品\n");}
}
void search_fro()//查询3
{
char from[20];
int i;
struct student *read(),*p;
p=read();
printf("请输入你要查询的商品产地:\n");
scanf("%s",&from);
for(i=0;i<M;i++);
if(strcmp(p->from,from)==0)
{printf("你要查询商品的相关消息是:\n");
("NO\tname\tnumber\tmoney\tfrom\t\n");
printf("%d\t%s\t%d\t%d\t%s\t",p->name,p->num,p->money,p->from);
}
else printf("暂时没有此商品:\n");
}
void search_nam()//查询4
{char name[20];
int i;
struct student *read(),*p;
p=read();
printf("请输入你要查询的商品名称:\n");
scanf("%s",&name);
for(i=0;i<M;i++);
{if(strcmp(p->name,name)==0)
{printf("你要查询商品的相关消息是:\n");
printf("NO\tname\tnumber\tmoney\tfrom\t\n");
printf("%d\t%s\t%d\t%d\t%s\t",p->NO,p->name,p->num,p->money,p->from);
}
else printf("暂时没有此商品:\n");}
}
void search_NO()//查询5
{int i,n;
struct student *read(),*p;
p=read();
printf("请输入你要查询商品的编号(1到60):\n");
scanf("%d",&i);
for(n=0;n<M;n++,p++)
{if(i=p->NO)
{printf("NO\tname\tnumber\tmoney\tfrom\t\n");
printf("%d\t%s\t%d\t%d\t%s\t",p->NO,p->name,p->num,p->money,p->from);}
else printf("we haven't this product\n");}
}
struct student *read()//读商品信息
{FILE *fp2;
int r;
if((fp2=fopen("student1.txt","rb"))==NULL);
{printf("不能打开student1.txt文件\n");
exit(0);}
for(r=0;r<60;r++)
{static struct student boy[M];
fread(&boy[r],sizeof(boy),1,fp2);
scanf("%d,%s,%d,%f,%s",&boy[r].NO,&boy[r].name,&boy[r].num,&boy[r].money,&boy[r].from);
fclose(fp2);
return(boy);
}
}
void insert()//输入商品信息
{struct student pd[M];
FILE *fp;
int i,n;
printf("请输入你准备输入的商品的种数:\n");
scanf("%d",&i);
if(i>60||i<1)
{printf("超出存储产品的种类数\n");
return;}
else printf("请输入产品的编号、名称、数量、单价、产地\n");
scanf("%d",&n);
if((fp=fopen("student1.txt","wb"))==NULL)
{printf("不能写入这个文件\n");
return;}
while(n<M)
{scanf("%d,%s,%d,%f,%s",pd[n].NO,pd[n].name,pd[n].num,pd[n].money,pd[n].from);
fwrite(&pd[n],sizeof(pd),1,fp);
scanf("%d",&n);
}
fclose(fp);
}
void menu1()//调用
{printf("**************************************************************\n\n");
printf("*****************1.1根据商品编号查找***************************\n");
printf("*****************1.2根据商品名称查找***************************\n");
printf("*****************1.3根据商品的产地查找*************************\n");
printf("*****************1.4根据商品的价格查找*************************\n");
printf("*****************1.5根据商品的数量查找*************************\n");
printf("***************************************************************\n\n");
}
void search()//查看商品相关内容
{int ch;
menu1();
switch(ch)
{case 1:search_NO();break;
case 2:search_nam();break;
case 3:search_fro();break;
case 4:search_mey();break;
case 5:search_num();break;
}
}
void mainmenu()
{printf("******************************************************\n\n");
printf("*****************1.查看商品相关内容*******************\n");
printf("*****************2.输入商品相关信息*******************\n");
printf("*****************3.销售员销售记录与查询***************\n");
printf("*****************4.修改相关产品信息*******************\n");
printf("*******************************************************\n\n");
}
void main()
{int ch;
mainmenu();
switch(ch)
{case 1:search();break;
case 2:insert();break;
case 3:sale();break;
case 4:xiugai();break;
}
}
----------------------------------------------------------------------------------
Compiling...
2322.c
E:\C++\新建文件夹\2322.c(55) : error C2106: '=' : left operand must be l-value
E:\C++\新建文件夹\2322.c(74) : error C2143: syntax error : missing ';' before 'type'
E:\C++\新建文件夹\2322.c(76) : error C2143: syntax error : missing ';' before 'type'
E:\C++\新建文件夹\2322.c(77) : error C2143: syntax error : missing ';' before 'type'
E:\C++\新建文件夹\2322.c(82) : error C2106: '=' : left operand must be l-value
E:\C++\新建文件夹\2322.c(213) : warning C4013: 'search_mey' undefined; assuming extern returning int
Error executing cl.exe.
2322.obj - 5 error(s), 1 warning(s)