+ 1

Please can someone tell me what us wrong with my c++ password validation program?

it keeps giving me false even wen I meet up with DE required conditions https://code.sololearn.com/cyGkhQ1He6Oh/?ref=app

21st Dec 2017, 7:58 AM
MBONJOH PANGWEH ALIYOU
MBONJOH PANGWEH ALIYOU - avatar
31 Antworten
+ 8
Okay, tell me what words did you try to test, because I can get a strong password message from the code. Are you sure the word has matched all the criteria? I mean any lower or upper case, number, and it is at least 8 characters long?
22nd Dec 2017, 2:52 AM
Ipang
+ 6
I run the code in Code Playground, with "Dco57der2" (without quotes), it tells me "The password is strong", I don't understand, did you get "The password is not strong"? that's odd, can you send me more words to test please?
22nd Dec 2017, 3:39 AM
Ipang
+ 5
Oh, sorry my friend, I was asleep when you replied, different timezones. Anyways, the criteria for a strong password is what you told me, at least a number (0-9), a lowercase letter, and an uppercase letter, I only add the minimum password length to the criteria, so it has to be >= 8 characters in length to be a strong (valid) password. Unfortunately I cannot answer the question for offline Android programming tool, honestly, I haven't got that far, sorry.
22nd Dec 2017, 12:10 AM
Ipang
+ 5
Okay, I put it into a saved code, please try this code, I have tested "Dco57der2" & " BAsgj34f7" and both was assumed strong password. I don't have any idea why are we seeing different results from this code, anyway, just give it a try : ) https://code.sololearn.com/czRa764RzlV5/?ref=app
22nd Dec 2017, 4:00 AM
Ipang
+ 5
Okay bro, yes I did modify it a little, added information about how many letters, and numbers in the password, and the length of the password also. You may use this code if you want bro, if it works for you. Anyways, I will not be available for the next two hours, as I am going to attend Friday prayer here, but I'll be back then, so see you later bro...
22nd Dec 2017, 4:16 AM
Ipang
+ 5
Brother try this, adjust the size of input according to your needs. #include <iostream> using namespace std; int main() { char input[50]; cin.getline(input,50); cout << input; return 0; }
22nd Dec 2017, 1:27 PM
Ipang
+ 4
Oh, sorry for the delay, yeah brother, I am a muslim : ) No problem at all bro, so can you tell me what was the problem before? I'm just really curious what happened...
22nd Dec 2017, 7:03 AM
Ipang
+ 4
Well bro, I guess we all been there, I most of the time make mistakes from forgetting the semicolon, still happens until now : ) Thanks for telling bro, I'm always curious when something goes wrong, and how to solve the problem. Salam,
22nd Dec 2017, 8:13 AM
Ipang
+ 3
What is the criteria for defining a password is good? maybe I can help you? Anyway can you link your code with the question? it's supposed to be linked with question related to code. Do you know how to link a code with a question? it's simple, open your code, tap on share button above, select an option that suggests to copy to clipboard, then go back to this question, from the menu to the right, pick Edit, then insert a blank line below question description, long press and tap on Paste. Go give it a try!
21st Dec 2017, 9:00 AM
Ipang
+ 3
I have a different way to approach the goal, then yours, this is how I would do it, you are welcome to use this if you decide so. #include <iostream> using namespace std; int main() { string password; // This records number of lowercase, // uppercase, and numbers int lower{0}, upper{0}, digits{0}; // character type, returned by isalpha int cc {0}; // Get password, save password length // Validate password is not empty cin >> password; if(password.empty()) { cout << "You entered empty password!"; return 0; } int len {password.length()}; for(size_t i = 0; i < len; i++) { // isalpha function returns 0 if the // character is non alphabetical, // 1 for uppercase, 2 for lowercase cc = isalpha(password[i]); if(cc == 1) // Increment uppercase letter count upper++; else if(cc == 2) // Increment lowercase letter count lower++; else { if(isdigit(password[i])) // Increment number count digits++; } } // All these three must be nonzero for // a password to be classified as strong. // Plus, a minimum length of 8 characters. if(upper && lower && digits && (len >= 8)) cout << "The password is strong"; else cout << "The password is not strong"; return 0; } Hth, cmiiw
21st Dec 2017, 3:36 PM
Ipang
+ 3
Brother, sorry for the delay, I don't understand what you mean here, what do you need to initialize? I lookup for that strstr function, it seems to be used for finding a string inside another string, can you tell me what's the problem? I'll see what I can do.
22nd Dec 2017, 12:43 PM
Ipang
+ 1
It's hard to me understand it u.u I don't remember much of C, but I modified your code printing the three status and analyzed some passwords. All pass with no numbers were right except with stronger. Try to cout those values, how you know the code, it can be a little more easy to detect errors :)
21st Dec 2017, 9:00 AM
Sebastián Zapata
Sebastián Zapata - avatar
+ 1
please Ipang check well it keeps giving me the password is not strong even wen I meet DE conditions
21st Dec 2017, 7:42 PM
MBONJOH PANGWEH ALIYOU
MBONJOH PANGWEH ALIYOU - avatar
+ 1
I tried Dco57der2
22nd Dec 2017, 2:52 AM
MBONJOH PANGWEH ALIYOU
MBONJOH PANGWEH ALIYOU - avatar
+ 1
merde. then am confused cuz everything I put here it gives me password is not strong. how I wish I could just send u a picture of how it runs on my machine.
22nd Dec 2017, 3:42 AM
MBONJOH PANGWEH ALIYOU
MBONJOH PANGWEH ALIYOU - avatar
+ 1
well try BAsgj34f7
22nd Dec 2017, 3:42 AM
MBONJOH PANGWEH ALIYOU
MBONJOH PANGWEH ALIYOU - avatar
+ 1
OK thanks much bro. let me try
22nd Dec 2017, 4:08 AM
MBONJOH PANGWEH ALIYOU
MBONJOH PANGWEH ALIYOU - avatar
+ 1
hey bro it works. let me check where I made DE mistake although you have modified this one somehow
22nd Dec 2017, 4:11 AM
MBONJOH PANGWEH ALIYOU
MBONJOH PANGWEH ALIYOU - avatar
+ 1
OK brother so you are a muslim???
22nd Dec 2017, 4:22 AM
MBONJOH PANGWEH ALIYOU
MBONJOH PANGWEH ALIYOU - avatar
+ 1
thanks much bro.
22nd Dec 2017, 4:22 AM
MBONJOH PANGWEH ALIYOU
MBONJOH PANGWEH ALIYOU - avatar