Life,the universe, and everything

The link to the question is here-

So I have checked out he successful submissions and what they do is that they print the number right after its been scanned and the program stops taking input after 42 has been entered. I code in C. Please help its my first question here.