+ 1
Why is my password validation code not WORKING!?
#include <iostream> #include <string> bool isValidPassword(const std::string& password) { int numCount = 0; int specialCharCount = 0; for (char c : password) { if (isdigit(c)) { numCount++; } else if (c == '!' || c == '@' || c == '#' || c == '
#x27; || c == '%' || c == '&' || c == '*') { specialCharCount++; } } return numCount >= 2 && specialCharCount >= 2 && password.length() >= 7; } int main() { std::string password; std::cout << "Enter the password: "; std::cin >> password; if(isValidPassword(password)){ std::cout << "Strong" << std::endl; } else { std::cout << "Weak" << std::endl; } return 0; }4 Respostas
+ 2
Do not paste code into the description. Link your code. Format your code. Make it readable.
+ 1
Can you link me to your code on your profile
+ 1
In case this is a sololearn task, pay close attention to the output: Only output as described in the instructions – nothing additional, no input prompts.
0
I tried it and ran into no problems, everything seems to work as intended. Did multiple tests all with different conditions of input