C语言函数问题error C2143: syntax error : missing ';' before 'type' 10
voidsearch()/*信息查询函数*/{charf;structWorkerworker;FILE*fp;intflag;/*flag为1按编号查询,flag为2按...
void search()/*信息查询函数*/
{
char f;
struct Worker worker;
FILE * fp;
int flag; /*flag为1按编号查询,flag为2按姓名查询*/
int total=0 ;/*记录符合条件的纪录的个数*/
if((fp=fopen("f:\\inform.txt","rb"))==NULL)
{
printf("\t打开文件失败!");
getchar();
exit(1);
}
do
{
rewind(fp);
printf("\n\n查询(1:工号 2:姓名):[ ]\b\b");
while(1)
{
scanf("%d",&flag);getchar();
if(flag<1||flag>2)
printf("输入错误!!!请重新输入(1:工号 2:姓):[ ]\b\b");
else
break;
}
if(flag==1) /*按编号进行查询*/
{
char ch[10];
printf("请输入你想查找的职工号:");
gets(ch);
total=0; /*符合条件的记录数*/
while(fread(&worker, sizeof(worker),1,fp)==1)
if(strcmp(ch,worker.num)==0)
{
total++;
if(total==1)
print1();
print2(worker);
}
}
else /*按姓名进行查询*/
{
printf("请输入你想查找的职工的姓名:");
char ch[15];
gets(ch);
total=0;
while(fread(&worker,sizeof(worker),1,fp)==1)
if( strcmp(ch,worker.name)==0)
{
total++;
if(total==1)print1();
print2(worker);
}
}
printf("\n\n\tT一共有 %d 条记录!\n",total);
printf("要继续查找吗?(Y/N):[ ]\b\b");
f=getchar();getchar();
}
while(f=='Y'||f=='y');
fclose(fp);
}
还有这些
error C2065: 'ch' : undeclared identifier
(184) : warning C4047: 'function' : 'char *' differs in levels of indirection from 'int '
(184) : warning C4024: 'gets' : different types for formal and actual parameter 1
(187) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int '
(187)warning C4024: 'strcmp' : different types for formal and actual parameter 1
执行 cl.exe 时出错. 展开
{
char f;
struct Worker worker;
FILE * fp;
int flag; /*flag为1按编号查询,flag为2按姓名查询*/
int total=0 ;/*记录符合条件的纪录的个数*/
if((fp=fopen("f:\\inform.txt","rb"))==NULL)
{
printf("\t打开文件失败!");
getchar();
exit(1);
}
do
{
rewind(fp);
printf("\n\n查询(1:工号 2:姓名):[ ]\b\b");
while(1)
{
scanf("%d",&flag);getchar();
if(flag<1||flag>2)
printf("输入错误!!!请重新输入(1:工号 2:姓):[ ]\b\b");
else
break;
}
if(flag==1) /*按编号进行查询*/
{
char ch[10];
printf("请输入你想查找的职工号:");
gets(ch);
total=0; /*符合条件的记录数*/
while(fread(&worker, sizeof(worker),1,fp)==1)
if(strcmp(ch,worker.num)==0)
{
total++;
if(total==1)
print1();
print2(worker);
}
}
else /*按姓名进行查询*/
{
printf("请输入你想查找的职工的姓名:");
char ch[15];
gets(ch);
total=0;
while(fread(&worker,sizeof(worker),1,fp)==1)
if( strcmp(ch,worker.name)==0)
{
total++;
if(total==1)print1();
print2(worker);
}
}
printf("\n\n\tT一共有 %d 条记录!\n",total);
printf("要继续查找吗?(Y/N):[ ]\b\b");
f=getchar();getchar();
}
while(f=='Y'||f=='y');
fclose(fp);
}
还有这些
error C2065: 'ch' : undeclared identifier
(184) : warning C4047: 'function' : 'char *' differs in levels of indirection from 'int '
(184) : warning C4024: 'gets' : different types for formal and actual parameter 1
(187) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int '
(187)warning C4024: 'strcmp' : different types for formal and actual parameter 1
执行 cl.exe 时出错. 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询