Password Verifier, trouble verifying password

Trouble getting this to run through checking the password properly, please help. I have been running through this for a week now. I can't seem to find my error.

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


//verify uppercase letter is present
bool testUpper (char psword [])
{
	int length = strlen(psword);
	int count;
	for (count = 0; count < length;  count++)
	{
		if (!isupper (psword[count]))
			return false;
	}
	return true;
}

//verify lowercase letter is present
bool testLower (char psword [])
{
	int length = strlen(psword);
	int count;
	for (count = 0; count < length;  count++)
	{
		if (!islower (psword[count]))
		return false;
	}
	return true;
}

//verify a digit is present
bool testDigit (char psword [])
{
	int length = strlen(psword);
	int count;
	for (count = 0; count < length;  count++)
	{
		if (!isdigit (psword[count]))
		return false;
	}
	return true;
}

/*

*/
Last edited on
Why check if there is no digit/upper-lower-case, when you can just check if there is? Works much better that way, and I got it to work.

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
bool testUpper(char psword[])
{
	
	int length = strlen(psword);
	int count;
	for (count = 0; count < length; count++)
	{
		if (isupper(psword[count])) // checks if there is an uppercase Letter
		{
			return true;
		}
	}
	return false;
}

//verify lowercase letter is present
bool testLower(char psword[])
{
	int length = strlen(psword);
	int count;
	for (count = 0; count < length; count++)
	{
		if (islower(psword[count])) // checks if there is an lowercase Letter
			return true;
	}
	return false;
}

//verify a digit is present
bool testDigit(char psword[])
{
	int length = strlen(psword);
	int count;
	for (count = 0; count < length; count++)
	{
		if (isdigit(psword[count])) // checks if there is a digit
			return true;
	}
	return false;
}
Last edited on
Thank you!! I changed that and it works perfectly now. I tend to over think simple things. I appreciate the help.
Topic archived. No new replies allowed.