我已经有一段时间了,真的可以使用一些帮助。我正在制作一个密码程序,其中一个功能测试开头和结尾之间的字符是否有中间大写字母。这是我尝试过的:
int hasMiddleUpper(char *pass) {
int test=0, testu=0, testl=0, count;
char c;
while (c = *pass++) {
test++;
}
pass = pass - test + 1;
while (c = *pass++) {
if ( isupper( c )) {
testu=1;
}
}
pass--;
while (c = *pass++) {
if ( isupper(c )) {
testl=2;
}
}
count = testu + testl;
if (count==1) {
return 1;
}
else {
return 0;
}
}
int pwstrength( char *pass )
{
int test, test1,test2, test3, result;
test= hasUpperAndLower( pass );
test1 = hasAlphaDigits(pass);
test2 = hasEightOrMore(pass);
test3 = hasMiddleUpper(pass);
result = test + test1 + test2 + test3;
return result;
}
int main( void ) {
int a;
char *p= "Pass3wordD";
a= pwstrength( p );
printf( "%d \n", a );
system("Pause");
}