Hey guys! I got super behind in my C++ class and I feel like I dont really know what I am doing. I've been trying to piece together from other examples of password coding, but I got a little lost in the sauce. Anyways, the requirements for this program is that the user is to type a password, be told if their password meets the requirements, and then verify their password by typing it again. The requirements are that the password have 1 uppercase 1 lowercase a symbol and is at least 8 digits long. My coding is not complete, so I know it wont run, however this is what I have so far:
#include <iostream>
#include <string>
using namespace std;
void PassReq(string& input)
{
int n = input.length();
bool lowercase = false, uppercase = false;
bool special = false;
string normalChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 ";
for (int i = 0; i < n; i++) {
if (islower(input[i]))
lowercase = true;
if (isupper(input[i]))
uppercase = true;
size_t special = input.find_first_not_of(normalChars);
if (special != string::npos)
special = true;
}
if (lowercase && uppercase && special && (n >= 8))
cout << "Password Valid" << endl;
else
cout << "Password Invalid. Please try again." << endl;
}
int main()
{
cout << "Please type your password:" << endl;
cin >> >> endl;
PassReq(input);
return 0;
}
My question is what would I use to clarify that the user is inputting a password because when I tried to declare "char PassWord" I was told it was incompatiable with my void. Also after passing the requirements, how do I turn it into a loop that checks one more time? I got stuck and could really use some help. Please let me know :) thanks