for (int i= 0; i<length; i++)
{
if (isupper(password[i]))
upperflag = true;
else if (islower(password[i]))
lowerflag = true;
else if (isdigit(password[i]))
digitflag = true;
}
if (!upperflag)
cout << "Invalid Password. Please Include At Least One Upper Case And One Lower Case Letter." << endl;
if(!lowerflag)
cout << "Invalid Password. Please Include At Least One Upper Case And One Lower Case Letter." << endl;
if (!digitflag)
cout << "Invalid Password. Please Include A Number." << endl;
it asks user to enter a password and it has to be contain a upper letter, a lower letter and a digit.
if not, it will show a message.
i don't to what's wrong with my code. the function isn't working. it doesn't test the password.
Thank you
do {
cout << "Enter your password:";
cin >> password;
length = strlen( password );
} while( length < 6 );
// what if the password is more than 20 characters?
if( length > 6)
pass = test_password( password, length );
The length is already guaranteed to be at least 6 in the while loop. If you do if( length > 6), you are purposefully ignoring checking passwords with length of 6. It is a miserable mistake.