sinθ
sinθ

Reputation: 11493

Strange output in Eclipse CDT counsul

I'm getting the following on eclipse CDT when I run my program:

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"

Everything up to "Enter Move" makes sense, but the rest does not. After this comes up, it keeps letting me type things in, but the program seems to be frozen.

I have a lot of code, so here are just the pertinent parts:

Main function:

int main() {
    int sticks = 10;

    PlayerUser u(sticks);
    PlayerComputer c(sticks);

    StickGame game (u, c);
    game.startGame(11);
    return 0;
}

Function: 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;
}

From what I've been able to find, it seems like it may have something to do with a "Verbose console mode", but I don't understand what that is or how to fix it.

Upvotes: 1

Views: 608

Answers (1)

Nenad Bulatović
Nenad Bulatović

Reputation: 7444

I had same problem in debugger every time I was using cin right after cout, and finally I resolved it with adding << endl; after cout

bool isDone()
    {
        char c;
        cout << "Enter 'Y' if food is done:";
        cin >> c;
        return ((c == 'Y') || (c == 'y'));
    }

This was generating error such as:

*stopped,reason="end-stepping-range",frame=...

But this is working just fine:

bool isDone()
    {
        char c;
        cout << "Enter 'Y' if food is done:" << endl;
        cin >> c;
        return ((c == 'Y') || (c == 'y'));
    }

Upvotes: 1

Related Questions