运行程序时,我在Eclipse CDT上收到以下内容:There are 11 sticks left.3Enter Move:*stopped,reason="end-stepping-range",frame={addr="0x004015b4",func="_fu4___ZSt3cin",args=[],file="..\src\PlayerUser\PlayerUser.cpp",fullname="C:\Users\...\Desktop\workspace_eclipse\StickGame\src\PlayerUser\PlayerUser.cpp",line="26"},thread-id="1",stopped-threads="all"直到“Enter Move”为止的所有内容都是有意义的,而其余的则没有意义。出现这种情况后,它一直让我输入内容,但该程序似乎被冻结了。我有很多代码,所以这里只是相关的部分:主功能:int main() { int sticks = 10; PlayerUser u(sticks); PlayerComputer c(sticks); StickGame game (u, c); game.startGame(11); return 0;}函数:PlayerUser::getMoveint PlayerUser::getMove(int n_left){int on = 0;while(true){ cout << "There are " << n_left << " sticks left." << endl; cout << "Enter Move:" << flush; //where error occurs cin >> on; if(on <= 3 && on >= 1) break;}setMove(n_left, on);return on;}根据我的发现,似乎它与“详细控制台模式”有关,但是我不知道这是什么或如何解决。 最佳答案 每次在 cout 之后立即使用 cin 时,我在调试器中都遇到了同样的问题,最后我通过添加 之后的 cout bool isDone() { char c; cout << "Enter 'Y' if food is done:"; cin >> c; return ((c == 'Y') || (c == 'y')); }这正在生成错误,例如:*stopped,reason="end-stepping-range",frame=...但这很好用:bool isDone() { char c; cout << "Enter 'Y' if food is done:" << endl; cin >> c; return ((c == 'Y') || (c == 'y')); }关于c++ - Eclipse CDT咨询中的奇怪输出,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14887668/ 10-17 00:19