Problem of using cin twice

前端 未结 6 1043
攒了一身酷
攒了一身酷 2020-12-01 13:27

Here is the code:

string str;
cin>>str;
cout<<\"first input:\"<

        
6条回答
  •  难免孤独
    2020-12-01 14:05

    By default, the stream insertion operator reads until it sees whitespace. Your first call isn't returning until it sees a space, tab, newline, etc. Then the next character needs to be consumed so that you can get to the next one.

提交回复
热议问题