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.
12/25/2019 7:14:41 AMVijay Adithya
12 AnswersNew Answer
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.
Yup really strange. I got it passed only after inserting a scanf statement.
Well you need to show the code so that someone can figure out why it is not working.
No it is not. It will only show the problem statement and if you click the language link it will show one's own code if they have written else blank or default generated code.
Ok, i'll check it.
Where is a scanf statement in your code ? You are not reading the password at all. Your test cases are passing by fluke Also you are starting with i = n-1, then your for loop should have i -- instead of i++ Also isspace check is redundant. passwords don't have spaces in them (at least i have never seen it)
That is strange that it is taking the input without a scanf statement. Ideally you should have scanf statement else the code is not useable outside code coach
Vijay Adithya I tried your code in code coach(after the necessary correction and without reading the password) it is failing for me. How come it is passing for you?
Sounds strange but it's true..might be some mistake in app..
~ swim ~ pls check now..inserted the code
~ 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.
by clicking link and then select code then C.you can see my code.