You are not logged in. Please login at to post your questions!


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

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

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.

asked 25 Dec '13, 13:32

vinayawsm's gravatar image

accept rate: 24%

closed 28 Dec '13, 14:17

kunal361's gravatar image


The question has been closed for the following reason "The question is answered, right answer was accepted" by kunal361 28 Dec '13, 14:17

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


answered 25 Dec '13, 15:46

kunal361's gravatar image

accept rate: 21%

edited 25 Dec '13, 15:48

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

(25 Dec '13, 16:52) kunal3614★

@kunal361 ok i understood.. thank you

(28 Dec '13, 14:04) vinayawsm4★

glad could help...:)

(28 Dec '13, 14:17) kunal3614★

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 25 Dec '13, 13:32

question was seen: 1,186 times

last updated: 28 Dec '13, 14:17