代码如下:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int len = 0;
char password[10] = {0};
printf("请输入密码:");
scanf("%s", password);
len = strlen(password);
if (len < 5) {
printf("密码长度不足!\n");
}
else if (len > 5) {
printf("密码长度过长!\n");
}
else {
// 默认密码是 admin
if (strcmp(password, "admin") == 0) {
printf("登录成功!\n");
}
else {
printf("密码不正确!\n");
}
}
system("pause");
return 0;
}