Here is the code:
string str; cin>>str; cout<<\"first input:\"<
As others have said, th problem is that the newline is left from the first extraction. One solution I do is to discard all the left characters in the stream:
std::cin.ignore( std::numeric_limits::max(), '\n' );