That is because getchar() function requires a return key to be hit after every char you enter. As an effect you never enter the loop at all. You can read through this FAQ to find out how to read from stdin without entering 'enter'.

FAQ > How can I get input without having the user hit [Enter]? - Cprogramming.com

As a matter of getchar() is the function you want.

~H