扫码关注官方订阅号
输入一段文章,没有给出单词数,用cin循环获取每个单词,如何在文章结束处让循环停止?如:输入:to be or not to be is a question代码:
string a; while( ? ) //无法停止循环 { cin >> a; // Do some thing... }
while(cin >> a) { // Do some thing... } cin在读取输入流的末尾是会设置标记位failbit为false
if(a == "quit") break;
PHP学习
技术支持
返回顶部