相关疑难解决方法(0)

如何在循环中表示字符串ss不再输入(cin >> ss)

我用"cin"来读取输入流中的单词,就像

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

    // perform some other operations
}
Run Code Online (Sandbox Code Playgroud)

代码结构类似于上面的代码结构.它是可编译的.在执行期间,我继续输入类似的内容

aa bb cc dd
Run Code Online (Sandbox Code Playgroud)

我的问题是如何结束这个输入?换句话说,假设文本文件只是"aa bb cc dd".但我不知道如何让程序知道文件结束.

c++ file-io cin eof

12
推荐指数
2
解决办法
5万
查看次数

标签 统计

c++ ×1

cin ×1

eof ×1

file-io ×1