Remember you need to press [enter] after you have completed your input.
I've a feeling you wanted the input to be recognised as completed when you press some other key. If that's what you want, you'd need to monitor individual keystrokes, instead of simply using cin.