这是我主要使用的功能。问题在于char
任务。
void takeTurn(int *iap, int *tile, char *cap) {
//*iap is 1 right now
printf("\nThe current active player is %d. His character is %c", *iap, *cap);
//prints The current active player is 1. His character is q.
if (*iap == 1) *cap == 'X';
if (*iap == 2) *cap == 'O';
printf("\nThe current active player is %d. His character is %c", *iap, *cap);.
//prints The current active player is 1. His character is q.
. . .
}
需要做什么才能*cap
将正确的char
分配给正确的有效玩家?
答案 0 :(得分:2)
您正在使用=
等式比较运算符,而您应该使用*cap == 'X';
*cap == 'O';
赋值运算符。
更改这些陈述:
*cap = 'X';
*cap = 'O';
改为:
///test.c
#include <stdio.h>
int main(){
double d = 13.37;
char buf[128];
snprintf(buf, 128, "%f", d);
return 0;
}