-1

我有以下代码:

void doPlayerMove(void)
{
    bool moved = false;

    while (!moved) 
    {
        printf("\nWhere is the piece you want to move?(rc):");
        int r = getchar() - '0';// gets the row number
        int c = getchar() - '0';// gets the column number

        printf("%d:%d", r, c);// prints the chosen row/column

        clearInput();
        printf("\nWhere is the space you want to move to?(rc):");
        int r2 = getchar() - '0';
        int c2 = getchar() - '0';

        printf("%d:%d", r2, c2);

        ...
    }
}

void clearInput(void)
{
    while(getchar() != '\n');
}

这是我得到的输出:

Where is the piece you want to move?(rc):51
5:1
Where is the space you want to move to?(rc):40
4:00

多余的 0 是怎么回事?有谁看到问题出在哪里?

4

1 回答 1

0

正如 OP 在评论中所说:

问题解决了,这是我在调用的某个函数的一些输出......抱歉误报!

于 2012-06-29T05:48:06.010 回答