Password verification ASAP..

Hey,

I am working on a project to verify a password with 6 minimum and a digit.
Heres the code i have for now.

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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <iostream>
#include <cstring>
using namespace 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.
Last edited on
In your while loop, you never call verifyPassword() again.
i figured it out i was returning an integer within a boolean function and my while loop was a little messed up. thanks!!
Topic archived. No new replies allowed.