vendredi 13 mars 2020

Password check if statements

How do I make a password check that prints out every error with the password? If there are no errors it needs to return 0.

This is what I have now it works until I submit a password with an upper and a lowercase letter. I have tried to do nested if statements but I have not found a way to do it efficiently make it work. Any advice?

int isSafePassword(char password[])
{
        if((passwordIsLongEnough(password))!=0)
            printf("\nThis password is not long enough.");

        if((passwordContainsDigit(password))!=0)
            printf("\nThis password does not contain a digit!");

        if((passwordHasMixedCase(password))!=0)
            printf("\nThis password does not contain a mix of small/upper-case letters");

        else
            return 0;
}

Aucun commentaire:

Enregistrer un commentaire