There is nothing wrong with the snippet you posted. You need to provide more content.
Can you post the output you get when you compile it?
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.
fpiro i tried your code in VS2012 and it works perfectly.
Still the same problem. I mixed up the extraction operator ">>" with the getline function. Solved! √