Okay, here I am again. I searched the forum and found the posts that I need to solve this password validator, but I'm not putting it together in my head correctly for some reason. I haven't started the isUpper, isLower, and isDigit functions, but I'm going to do those next.
#include<iostream>
#include<cstring>
using namespace std;
//function prototypes
bool IsValidPassword(char[]);
int main()
{
IsValidPassword(password);
return 0;
}
//function definitions
bool IsValidPassword(char password[])
{
cout<< " Please enter a password at least six characters long,no longer than sixteen characters long,containing at least one uppercase and one lowercase letter, and containing at least one digit. "<<endl;
cin>>password;
for(int i =0;i< 5;i++)
{
if(strlen(password)<6 && strlen(password)>16)
return false;
}
return password;
}
I keep getting an error for "password was not declared in this scope" in main. I understand that the strlen function doesn't work for a character array, and I'm guessing that I can't make an array of strings? (that was a whole other can of worms). Can somebody point me in the right direction?
just in case it's needed, here is the assignment statement:
Filename: password.cpp
a) (7 points)
Imagine you are developing a software package that requires users to
enter their own passwords. Your software requires that users’ passwords
meet the following criteria:
- The password should be at least six characters long.
- The password should contain at least one uppercase and at least one
lowercase letter.
- The password should have at least one digit.
Write the following function:
bool IsValidPassword(string) that accepts the password as a string parameter and
returns a Boolean value whether or not the password is valid.
b) (3 points)
Test your function in main().