私は次のコードを持っています:
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はどうですか?誰かが問題がどこにあるかわかりますか?