c++关于cin作为while条件的问题

来源:互联网 发布:php贴吧盖楼源代码 编辑:程序博客网 时间:2024/05/20 03:06
void main(){
string str;
while (cin>>str)
{
cout << str << " ";
}
system("pause");
}
执行这段代码时为什么我在输入结尾输入 ctrl+z后不会退出循环呢,而是必须要回车
且在开头输入ctrl+z才能结束输入。
比如我这样输入:
a b c d e f g ctrl+z
敲回车,输出是
a b c d e f g ,但程序没结束,会让我继续输出,只有当我敲回车且在开头输入ctrl+z
程序才会结束
原创粉丝点击