How to signify no more input for string ss in the loop while (cin >> ss)

前端 未结 10 1447
情书的邮戳
情书的邮戳 2020-11-29 09:12

I used \"cin\" to read words from input stream, which like

int main( ){
     string word;
     while (cin >> word){
         //do sth on the input word         


        
10条回答
  •  清酒与你
    2020-11-29 09:55

    Hit Ctrl-Z (Ctrl-D on *nix systems) and hit enter. That sends an EOF and invalidates the stream.

提交回复
热议问题