请大家进来看看!

shaleniao 2003-09-13 05:02:26
我用这个运行时,输入了人员信息,可是当查找某年月前和后出生的人时出现了,某年月前的不可查,而后的却调出了所有人的信息!这是怎么回事,望高手不吝赐教!谢谢了
主要是这两个函数的问题,前者是查某年月前出生的 ,后者是查某年月后出生的!
void seek()
{
int k=0;
long int birthkey[8];
struct person one;

printf("\nenter birth:");
scanf("%ld",birthkey);

if((fp=fopen(filename,"rb"))==NULL)
{
printf("\nfail!");
exit(1);
}
while(!feof(fp))
{
fscanf(fp,"%s%s%s%s%s%s%s%s\n",one.name,one.id,one.sex,one.birth,one.prof,one.educat,one.salary,one.marriage);
if(birthkey<one.birth)
{
printf("\n\nfind,here is:");
printf("\n%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s\n",one.name,one.id,one.sex,one.birth,one.prof,one.educat,one.salary,one.marriage);
k=1;
}
}
if(!k)
printf("\n\nsorry,no such one!");
fclose(fp);
}
void shabi()
{
int k=0;
long int birthkey[8];
struct person one;

printf("\nenter birth:");
scanf("%ld",birthkey);

if((fp=fopen(filename,"rb"))==NULL)
{
printf("\nfail!");
exit(1);
}
while(!feof(fp))
{
fscanf(fp,"%s%s%s%s%s%s%s%s\n",one.name,one.id,one.sex,one.birth,one.prof,one.educat,one.salary,one.marriage);
if(birthkey>one.birth)
{
printf("\n\nfind,here is:");
printf("\n%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s\n",one.name,one.id,one.sex,one.birth,one.prof,one.educat,one.salary,one.marriage);
k=1;
}
}
if(!k)
printf("\n\nsorry,no such one!");
fclose(fp);
}
...全文
60 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

15,440

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧