注册账号软件 如何拦截用户名重复的BUG
struct record{char id[9];
char mm[7];
};
typedef struct record REC;
void ZC()
{ REC s;FILE *fp; char mm1[7];
fp=fopen("jhb.dat","a");
if(fp==NULL)
fp=fopen("jhb.dat","wb+");
printf("请输入你的用户名:");
scanf("%s",s.id);
if(strlen(s.id)>8)
{gotoxy(20,22);printf("请输入8位以内的用户名");
gotoxy(20,23);printf("按任意键重新输入");
system("pause");system("cls");ZC();}
while(1)
{fread(&s,sizeof(REC),1,fp);
if(strcmp(s.id,s.id)&&(feof(fp)!=0))
{gotoxy(20,22);printf("该用户名已存在");
gotoxy(20,23);printf("该任意键重新填写");
system("pause");system("cls");ZC();}
else {gotoxy(30,1);printf("该用户名可用\n");break;} }
printf("请输入你的密码:");
scanf("%s",s.mm);
while(strlen(s.mm)!=6)
{gotoxy(20,22);printf("请输入6位密码");
gotoxy(20,23);printf("按任意键重新输入");
system("pause");gotoxy(16,2);printf(" ");
gotoxy(16,2);scanf("%s",s.mm);}
printf("请重新输入密码:");
scanf("%s",mm1);
while(strcmp(s.mm,mm1))
{gotoxy(20,22);printf("两次密码输入不一样");
gotoxy(20,23);printf("按任意键重新输入");
system("pause");gotoxy(16,3);printf(" ");
gotoxy(16,3);scanf("%s",mm1);}
mm1[7]=" ";
fwrite(&s,sizeof(REC),1,fp);
fclose(fp);
红色颜色字体那段是用来判断用户名是否已经被注册的 当出现用户名重复时 我的代码没办法拦截··· 求高手指教