inputting strings

when i used to read a string character by character i get an error
but when i read the string as a whole by using scanf(%s") or gets i get the correct answer
can anyone explain why?
i have even included getchar to read the null character or end of file but i am not getting the correct answer

What problem are you referring to?