0

Can you please make this code correct being a Pro coder? Also explain what I did wrong.

Question is to check an entered password whether its a strong password or weak. Condition of strong : Password must contains at least 2 numbers, with any 2 symbols of them #, $, &, @, %, *, ! and with at least 7 or more digits/length. If all the conditions are met then it will print "Strong". Else : It will print "Weak". The code is : https://code.sololearn.com/cc0v0lQ19ccv/?ref=app

5th May 2021, 12:59 AM
iMiMofficial
iMiMofficial - avatar
1 Respuesta
+ 2
Why are you getting input in such a complicated way? You can just use scanf("%s", passwordAr) directly to get the whole password string. Then your check for numbers is wrong. Remember that you have to check for the characters which resemble the numbers and not the numbers themselves. So use '0' instead of 0. Also you don't have to check for each digit individually. You can just check if the character is between '0' and '9'. Somewhere at the end you are apparently trying to get the length of the string which you want to compare with 7. To do this you should use the function strlen() from the header <string.h> The way you do it currently is wrong and does not work.
5th May 2021, 11:01 AM
Hape
Hape - avatar