Password Verifier Syntax Help

My Do While Syntax is wrong. I can't get it right, either. It is changing the boolean like it's supposed to, but it isn't breaking correctly, therefore only using the last error checking function as the boolean passed to the while check. Anyone help?

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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//Title:		Password Verifier
//Date:		10/8/2012
//Purpose:	To verify a password entered by the user by certain guidelines

#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

bool CharCheck(char[], int, bool&);
bool UpperCheck(char[], int, bool&);
bool LowerCheck(char[], int, bool&);
bool DigitCheck(char[], int, bool&);

int main()
{
	//variables
	const int LENGTH = 80;			//max length for password
	char password[LENGTH];			//array of char
	bool incorrect = false;

	//title
	cout << "\t\t\t\tPASSWORD VALIDATOR\n\n\n\n\n";

	//loop for password validation
	do {
		if (incorrect)
			cout << "\n\n\n\tOops! Your password must meet the password criteria!\n\n";

		//get password
		cout << "\tPlease enter a password containing at least six characters \n"
			<< "\twith at least one digit 0-9, one uppercase letter, and one \n"
			<< "\tlowercase letter. ";
		cin.getline(password, LENGTH);

	switch(incorrect)
	{
		case 1: CharCheck(password, LENGTH, incorrect);			//Character check function
			if (incorrect) break;
		case 2: UpperCheck(password, LENGTH, incorrect);		//Lowercase check function
			if (incorrect) break;
		case 3: LowerCheck(password, LENGTH, incorrect);		//Lowercase check function
			if (incorrect) break;
		case 4: DigitCheck(password, LENGTH, incorrect);		//Digit check function
	}
	} while (incorrect);

	//clear screen
	system("cls");

	//title
	cout << "\t\t\t\tPASSWORD VALIDATOR\n\n\n\n\n";

	//display password verified
	cout << "\t\t****************************************************\n";
	cout << "\t\t\t\t   CONGRATULATIONS!\n";
	cout << "\t\t****************************************************\n";
	cout << "\n\n\n\n\t\t\t   Your Password Has Been Verified!";

	cout << endl << endl << endl << endl << endl << endl;
	
	system("pause");
	return 0;
}

/********************************************************************************************
|											FUNCTIONS										|
*********************************************************************************************/

//Character check function
bool CharCheck(char password[], int size, bool &incorrect)
{
	int length = strlen(password);
	
	//error check
	if (length >= 6)					//if length is >= 6 char return false
		incorrect = false;
	else					//if length is < 6 char return true
		incorrect = true;

	return incorrect;
}

//Uppercase check function
bool UpperCheck(char password[], int size, bool&incorrect)
{
	int length = strlen(password);

	for (int i = 0; i < length; i++)
	{
		if (isupper(password[i]))
			incorrect = false;
		else
			incorrect = true;
	}

	return incorrect;
}

//Lowercase check function
bool LowerCheck(char password[], int size, bool&incorrect)
{
	int length = strlen(password);

	for (int i = 0; i < length; i++)
	{
		if (islower(password[i]))
			incorrect = false;
		else
			incorrect = true;
	}

	return incorrect;
}

//Digit check function
bool DigitCheck(char password[], int size, bool&incorrect)
{
	int length = strlen(password);

	for (int i = 0; i < length; i++)
	{
		if (isdigit(password[i]))
			incorrect = false;
		else
			incorrect = true;
	}

	return incorrect;
}
Anyone?
At a quick look this is wrong

1
2
3
	switch(incorrect)
	{
		case 1: 


incorrect is a bool so cannot be 1, 2 3 etc...
Okay, I guess I had forgotten how switches work. I'll try and fix it later today.
Topic archived. No new replies allowed.