gpt4 book ai didi

c - 是什么导致了这种奇怪的输出?

转载 作者:行者123 更新时间:2023-11-30 19:49:44 24 4
gpt4 key购买 nike

我有以下代码:

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是怎么回事?有人看出问题出在哪里吗?

最佳答案

正如OP在评论中所说:

Problem solved, it was some output from some function i was calling in the ... sorry for the false alarm!

关于c - 是什么导致了这种奇怪的输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11255232/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com