1
我试图提高我糟糕的C技巧,所以我正在写一个tic tac toe程序。这只是第一步,但我希望在进入游戏本身的所有算法之前能够打印棋盘。我打算将1用于x和0用于圈,以便稍后可以使用总和。 我与海湾合作委员会(Ubuntu的)工作,并正在此错误:字符数组初始化器中的多余元素
xo.c:11:3: error: (near initialization for ‘board[0]’)
xo.c:11:3: error: excess elements in char array initializer
xo.c:11:3: error: (near initialization for ‘board[0]’)
xo.c:11:3: error: excess elements in char array initializer
xo.c:11:3: error: (near initialization for ‘board[1]’)
xo.c:11:3: error: excess elements in char array initializer
xo.c:11:3: error: (near initialization for ‘board[1]’)
xo.c:11:3: error: excess elements in char array initializer
xo.c:11:3: error: (near initialization for ‘board[2]’)
xo.c:11:3: error: excess elements in char array initializer
xo.c:11:3: error: (near initialization for ‘board[2]’)
我想发起3×3的2维阵列,用于电路板。我不明白为什么会有过剩,我初始化了[3] [3]并输入了9个元素。这是我写的代码:
#include<stdio.h>
/***** Create two dimensional array full of blank spaces
1 marks the X , 0 marks the circle.
Let use enter coordinates (line and coloumn) for placing the 1 (x) and automatically print the board with the computers' move.
*****/
int i = 0;
int j = 0;
void main() {
char board[3][3] = {
{" " , " " , " "} , {" " , " " , " "} , {" " , " " , "t"}
};
for(i=0 ; i<3 ; i++) {
for(j=0 ; j<3 ; j++) {
printf("%c " , board[i][j]);
}
printf("\n");
}
}