只是写了部分主要的代码
typedef struct user
//用户名,密码
{
char user[20];
char password[20];
struct user *next;
}USER;
void mmm()
{
char admin_user[20];
char admin_password[20];
char password[20];
int result=1;
int count=0;
//计数器
int flag=1;
//开关
int j=0;
int i=0;
do
//控制连续输错的次数不能超过3次
{
flag=0;
printf("\t\t
用户名:");
scanf("%s",admin_user);
printf("\t\t
密
码:");
//密码以 * 号显示
while(i<PASSWORD_LENGTH && ((password[i]=getch())!='\r'))
{
if(password[i]=='\b')
{
password[i]='\0';
password[--i]='\0';
putchar('\b');
putchar(' ');
putchar('\b');
i--;
j--;
}
else
{
admin_password[j++]=password[i];
putchar('*');
i++;
}
}
printf("\n");
if(strcmp(admin_user,"admin")==0 && strcmp(admin_password,"123456")==0)
{
printf("\t\t成功登录......\n");
}
else
{
flag=1;
count++;
system("cls");
printf("\t\t登录失败...(您还可以输入 %d 次,请谨慎...)\n\n",4-count);
}
}while(count!=4&&flag==1);
while(count==4)
{
sleep(500000);
return ;
}
}