我正在阅读以下内容std::cin with a while循环结束时EOF被介绍。退出循环后,我调用std::cin.clear()使流恢复正常并再次读取,但它没有进入第二个循环。
我已经检查过eofbit它被设置为false. The failbit被设定为false以及goodbit被设定为true. The gcout清除后是0。这是我正在运行的代码:
while (getline(std::cin, person)) {
// Do stuff until I enter ^D
}
std::cin.clear();
// Adding std::cin >> person here doesn't work either
while (getline(std::cin, person)) {
// It never enters this loop
}