cin works but getchar() doesn't while taking a char input

these are my two solutions for marblegf during december long challange.

http://www.codechef.com/viewsolution/3085218

http://www.codechef.com/viewsolution/3078607

look at both the solutions. the only difference is when i used getchar_unlocked() in taking an input for character in every test case, resulted me as a wrong answer. whereas when i changed it to cin it is accepted.

can anyone pls explain why does that happen. where does getchar() result wrong in taking a character.

1 Like

i had also got that error…this soln got AC…LINK…maybe there is a space before the ‘\n’ hence the error is generated!!!

1 Like

i think @kuruma can explain if there is any such error in the test file…!!!

@kunal361 ok i understood… thank you

1 Like

glad could help…:slight_smile: