+ 2

code coach Password validation

My program is not working with 2 out of 6 test cases. pls tell me where i have gone wrong. https://www.sololearn.com/coach/76?ref=app https://code.sololearn.com/cKDakPZfV6bY/?ref=app Wrote the code in C.. Thanks in Advance.

25th Dec 2019, 7:14 AM
Vijay Adithya
Vijay Adithya - avatar
5 Respuestas
+ 3
The aren't much changes needed in code but these: 1.scanf, thats ought to cause the problem. No where was it mentioned in the problem that a password can't contain a space hence there might be one in it and since scanf() takes an input until the first space or newline is encountered for a password like this "he12 @!world" it will only read "he12". So instead use fgets() like this: fgets(pwd,30,stdin);//reads 30 characters from standard input and stores it in char array pwd.It stops reading if only newline is encountered 2.No need for the isspace() as it is redundant as mentioned and hence not required. 3.You should prefer using the i++ instead of the i-- ,as it's easier to read and convinient.
21st Jan 2020, 2:51 PM
Zohaib AK
Zohaib AK - avatar
+ 2
Sounds strange but it's true..might be some mistake in app..
25th Dec 2019, 7:53 AM
Vijay Adithya
Vijay Adithya - avatar
+ 1
~ swim ~ pls check now..inserted the code
25th Dec 2019, 7:24 AM
Vijay Adithya
Vijay Adithya - avatar
+ 1
~ swim ~ Thank you so much.Just executed the code successfully.Real problem lied in using i++ instead of i--.Scannig of string dosent making sense at all in that program.It is showing same output for no scanning string also.
25th Dec 2019, 7:42 AM
Vijay Adithya
Vijay Adithya - avatar
0
by clicking link and then select code then C.you can see my code.
25th Dec 2019, 7:18 AM
Vijay Adithya
Vijay Adithya - avatar