#include <iostream>
#include <cstring>
usingnamespace std;
//Function prototypes
bool verifyPassword(char *);
int verifyNum(char *);
int verifyLength(char *);
int main()
{
char password[50];
cout << "Enter a password with a minimum of 6 characters and at least one digit: ";
cin >> password;
bool verify;
verify = verifyPassword(password);
int length = strlen(password);
if(length >= 6)
{
while(!verify)
{
cout << "Please enter a new password with the correct criteria: ";
cin >> password;
}
cout << "The password " << password << " " << "is valid.";
}
else
{
cout << "Your password must be greater than 6 characters long.";
cin >> password;
}
system("pause");
}
bool verifyPassword(char *str)
{
int length = strlen(str);
return verifyNum(str);
}
int verifyNum(char *str)
{
int num = 0;
int len = strlen(str);
for (int count = 0; count < len; count++)
{
if (!isdigit(str[count]))
num++;
}
return num;
}
In the main function the if function when i dont insert a number it still says the password is valid. It prompts me to ask for the password if it is less than 6 characters that part works. I would like any advice on how to fix this, Thank you.