Using fflush gives WA

These two codes are the same: code1 and code2, the only difference being that I have used fflush(stdin) in the second code to omit the newline character while taking two strings as input one after the other and used a temporary string to do the same in the first code. The first solution was accepted while the second one was adjudged as wrong answer. Any reasons for this?

fflush not only clears the character u want to remove but also the input from the input files which is present in the buffer at that time!
So its better to use something like getchar() to ensure that only the 1 undesirable character is removed!

//