A "strong password" program

The following program asks a user for a password and checks whether the password is strong or not. the strength is determined by the presence of at least one digit, one uppercase, and at least 8 characters. Everything seems to work fine except that the program is required to ask the user whether he wants to continue entering a "strong password". If the user enters Y(=yes), something weird happens. Instead of asking for another password, the program simply outputs the else statements associated with the if..else clause. For instance, if the user enters Y, the program outputs "Please enter a password. Not a reliable password........". Why is that happening?

//this program is supposed to validate the entry of a strong password

#include <iostream>
#include <cctype>
using namespace std;
bool strong_pass(char[], int);
int main()
{
const int size = 30; //allowing the user to enter a relatively bigger password
char password[size];
char go;


//Function call
do
{
cout << "Please enter a password " <<endl;
cin.getline(password, size);

if(strong_pass(password, size))
cout << "Strong password successfully entered" << endl;
else
{
cout << "Not a reliable password" << endl;
cout << "Enter at least one digit or one upper case letter." << endl;
}
//Prompting the user for another go
cout << "Would you like to enter another password? (Y or N) " << endl;
cin >> go;

//Input validation
while(toupper(go) != 'Y' && toupper(go) != 'N')

{
cout <<"Invalid input. Enter either Y or N " << endl;
cin >> go;
}
}while (toupper(go) == 'Y');
return 0;
}
bool strong_pass(char userinput[], int maxmin)
{

bool E = false;

//size validation
bool A = false;
if(strlen(userinput) >= 8 && strlen(userinput) <= 10)
A = true;

bool B = false;
int count = 0;
char binga;
while(userinput[count])
{
binga = userinput[count];

//deosn't really utilize the logical Or operation
if(isupper(binga)) //maybe the first occurence of an uppercase letter should be enough
B = true;
count++;
}
//testing for a lower case character
bool C = false;
int index = 0;
char terminator;
while(userinput[index])
{
terminator = userinput[index];
if(islower(terminator))
C = true;
index++;
}

//testing for a digit or a numeric input in the password
bool D = false;
int punter = 0;
char mcgrath;
while(userinput[punter])
{
mcgrath = userinput[punter];
if(isdigit(mcgrath))
D = true;
punter++;
}

// Using the logical AND operations to test the occurence of every single of the above conditions

E = A && B && C && D;

return E;
}
It is very hard to read code when it is not in [code] tags and properly formatted.

The problem you are having is that you are mixxing >> and getline(). Don't do that.
http://www.cplusplus.com/forum/beginner/20577/#msg107828

Hope this helps.
Topic archived. No new replies allowed.