//判断从控制台输入的密码是否正确
BOOL varifyPassWord(char passWord[] , int index)
{
BOOL result = YES;
int count = 3;
char originalPassWord[20] = {0};
strcpy(originalPassWord , allPassWord[index]);
//开始判断密码是否一样
while (1) {
if (strcmp(originalPassWord , passWord) == 0) {
result = YES;
break;//输入正确,跳出循环
} else {
printf("密码输入错误,请重新输入:\n");
count--;
if (count == 0) {
printf("24小时不能再输入密码\n");
break;
//程序此时应该结束
}else{
printf("还可以输入%d次密码\n" , count);
scanf("%s" , passWord);
}
result = NO;
}
}
return result;
}
时间: 2024-10-12 11:55:35