Namaskar C++ Guru Haru, I need help with this code, any input on this is appreciated: Sample output should be as follows: Please enter a password: Pass5 Passwords must be at least 7 characters long Please enter a password: northwest Passwords must include at least one uppercase letter Please enter a password: ALLCAPS Passwords must contain at least one lowercase letter Please enter a password: Transform5 Thank you, that is a valid password #include #include #include using namespace std; bool testPass(char[]); int main() { char *password; int length; int numCharacters; cout > numCharacters; while (numCharacters >= 7) { cout > password; length = strlen(password); while (length != numCharacters) { cout > password; length = strlen(password); } if (testPass(password)) cout << "Your password is valid." << endl; else { cout << "Your password is not valid. "; cout << "Please refer to the above warning message." << endl; } delete[] password; return 0; } bool testPass(char pass[]) { // flags bool aUpper = false, aLower = false, aDigit = false; for (int i = 0; pass[i]; ++i) if (isupper(pass[i])) aUpper = true; else if (islower(pass[i])) aLower = true; else if (isdigit(pass[i])) aDigit = true; if (aUpper && aLower && aDigit) return true; else return false; }
djblade · Nov 18, 2014 2:15 PM · 14,731 views
This works? #include #include using namespace std; bool validateLength(string); bool validateLowerCase(string); bool validateUpperCase(string); int main() { string input; bool validInput = false; while(!validInput) { cout>input; bool validLength = validateLength(input); bool validLowerCase = validLength && validateLowerCase(input); bool validUpperCase = validLowerCase && validateUpperCase(input); validInput = validLength && validLowerCase && validUpperCase; } cout -1) { return true; } } cout -1) { return true; } } cout<< "Password must contain upper case"; return false; }
prankster · Nov 18, 2014 5:44 PM
Seems formatting got screwed up..try below link to pastebin http://pastebin.com/Gv2pYdf3
prankster · Nov 18, 2014 5:46 PM
Prankster bro, I've no clue what I would do without you. Again, I thanks a bunch for helping me out and I mean it.
djblade · Nov 18, 2014 5:55 PM
This conversation is preserved exactly as it was on the original Sajha.com and can't accept new replies.
Start a New Discussion