【发布时间】:2013-04-20 06:08:04
【问题描述】:
为什么我的函数会出现此错误或类型冲突? 其中 player 只是我只想输出的一个角色,以显示下一个玩家将去哪里
错误
tictac.c:94: warning: format ‘%c’ expects type ‘int’, but argument 2 has type ‘char *’
tictac.c:94: warning: format ‘%c’ expects type ‘int’, but argument 2 has type ‘char *’
代码
void move(char player)
{
int place;
printf("player %c, enter placement: \n", &player);
scanf("%d", &place);
if (place == 1)
board[0][0] = player;
else if (place == 2)
board[0][1] = player;
else if (place == 3)
board[0][2] = player;
else if (place == 4)
board[1][0] = player;
else if (place == 5)
board[1][1] = player;
else if (place == 6)
board[1][2] = player;
else if (place == 7)
board[2][0] = player;
else if (place == 8)
board[2][1] = player;
else if (place == 9)
board[2][2] = player;
}
【问题讨论】:
-
因为您将 address 传递给 character 格式说明符?也许???诚然,许多 C 编译器错误有点神秘,但很难说得更清楚。它实际上告诉你格式说明符是什么,它期望什么,以及你实际上传递了什么。没有自动为您修复它,这是您所希望的最好的。
-
为什么会收到一个错误,告诉您为什么会收到错误?
-
使用
board[(place-1) / 3][(place-1) % 3] = player;而不是大量的if和else if可以提高速度和代码美观。