int main()
{
FILE *fp;
char username0[20]={""};
char passwd0[20]={""};
int s=0;
typedef struct users Users;
Users next={"","","",};
fp=fopen("data.txt","r+");
printf("请输入用户名");
scanf("%s",username0);
printf("请输入密码");
scanf("%s",passwd0);
while(s!=EOF)
{
s=fscanf(fp,"%s\t%s\t%s\t%d\n",next.username,next.passwd,next.name,&next.uid);
if((strcmp(next.username,username0)==0)&&(strcmp(next.passwd,passwd0)==0))
{
printf("%s\t",next.name);
printf("%d\n",next.uid);
/*此处增加函数*/
}
}//while(s!=EOF);//猜测原因:读到EOF时,程序继续执行一次,此时,值仍然是前一次读到的值,所以此处改用while替代do-while
fclose(fp);
return 0;
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-05
  • 2021-09-07
  • 2022-12-23
  • 2021-12-01
  • 2022-12-23
  • 2022-01-29
  • 2021-06-20
相关资源
相似解决方案