任何人都知道这个问题?它只检测第一个字符。我不知道这个问题,请帮忙。我找不到答案。多个if语句C 446
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
int main()
{
int password;
printf("Enter your password. \n");
printf("Password must contain an uppercase letter, a lowercase letter, and a number. \n");
scanf("%c", &password);
if(isupper(password)){
printf("Password meets requirement 1. \n");
}
if(islower(password)){
printf("Password meets requirement 2. \n");
}
if(isdigit(password)){
printf("Password meets requirement 3. \n");
}
return 0;
}
引擎收录在这里:http://pastebin.com/ZdDHgpx8 – pushcode
'isupper','islower'和'isdigit'对单个字符,而不是字符串操作。 – keithmo
您正在将单个字符读入一个应该是密码的int变量。这不是你如何使用scanf,整数变量或密码。 – Magisch