当我运行我的程序时,我在 eclipse CDT 上得到以下信息:
There are 11 sticks left.
3
Enter 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"
直到“进入移动”的所有内容都有意义,但其余的则没有。出现此问题后,它一直让我输入内容,但程序似乎被冻结了。
我有很多代码,所以这里只是相关的部分:
主功能:
int main() {
int sticks = 10;
PlayerUser u(sticks);
PlayerComputer c(sticks);
StickGame game (u, c);
game.startGame(11);
return 0;
}
函数:PlayerUser::getMove
int 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;
}
据我所知,它似乎与“详细控制台模式”有关,但我不明白那是什么或如何解决它。