gpt4 book ai didi

c - 为什么我收到此格式错误 ‘%c’ 需要类型 ‘int’

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

为什么我的函数会出现此错误或冲突类型?其中玩家只是一个我只想输出的角色,以显示下一个玩家是哪个玩家

错误

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

最佳答案

您不应该在 printf 中使用 &player

改变

printf("player %c, enter placement: \n", &player);

printf("player %c, enter placement: \n", player);

关于c - 为什么我收到此格式错误 ‘%c’ 需要类型 ‘int’,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16117282/

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