I want to create a password

I want to see how to create a password with these criteria, using these functions isdigit, isupper, islower, and etc.
The password must be at least 6 characters long
The password must contain at least one lowercase letter
The password must contain at least one uppercase letter
The password must contain at least one digit

so if the user fails to meet one of these criteria, I want to display an error message, and make them re-enter the password. Once a valid password is entered, I want to ask them to enter the password once more, if the password matches the original, display "password is now set", else force the user to start from the beginning again. I also want to assume that password maximum size is 80 characters long.

Here's my weak code so far:


#include <iostream>
#include <string>
#include <cctype>
using namespace std;



bool isdigit(string arr[], char Size);
bool islower(string arr[], char Size);
bool isupper(string arr[], char Size);

int main()

{
const char Size = 80;
string Password_length;






cout << "Enter your password";
cin >> Password_length;
for (int i = 0; i < Size - 1; i++){
Password_length[i];




return 0;

}





There are lots of ways this can be accomplished, but the one I would choose is declare a variable

int valid = 0;

Then in your loop, exclusive or valid with 1 whenever the character is a digit, 2 whenever its lowercase and 4 whenever uppercase. That way, at the end if valid == 7, the three criteria have been met.

Grabbing a hash tag of extraneous bits of code that can't even be compiled much less run is really not an indicator that you put any effort into at least trying. In your next example, at least enclose your code inside code tags and something that can actually be run.
Make sure the code looks clean and add on from here in this fashion.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <string>
#include <cctype>
using namespace std;



bool isdigit(string arr[], char Size);
bool islower(string arr[], char Size);
bool isupper(string arr[], char Size);

int main(){
const char Size = 80;
string Password_length;

cout << "Enter your password: ";
cin >> Password_length;
for (int i = 0; i < Size - 1; i++){
Password_length[i];
}

return 0;

}

Topic archived. No new replies allowed.