code to test a password

Problem :
Some websites impose certain rules for passwords. Suppose the password rules are as follows:
• A password must have at least eight characters.
• A password must consist of only letters and digits.
• A password should contain at least one uppercase letter.
• A password must contain at least two digits.
Write a program that prompts the user to enter a password and displays valid password if the rules are followed or invalid password otherwise.

I have something wrong with my code that I can't figure out what it is, any help appreciated!

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
27
28
29

#include <iostream>
#include <string>

using namespace std;

char password[8];
const int SIZE = 8;

bool verify_chars(char *input)
{
	bool valid;
	int length = strlen(input);

	if (length >= 8)
	{
		valid = true;
	}

	else
	{
		valid = false;
		cout << "The password must be at least 8 characters long" << endl;
	}

	return valid;
}

}
Last edited on
closed account (j3Rz8vqX)
What and where are these variables initialized:
1
2
strlen
g

Also, this line of code may be not be appropriate:
cin >> &g !t; input;
Got it thank you
Topic archived. No new replies allowed.