c - excess elements in char array initializer -
i'm trying improve lousy c skills i'm writing tic tac toe program. it's in first steps able print board before going whole algorithms of game itself. i'm planning use 1 x , 0 circle in order able use sums later. i'm working gcc (ubuntu) , getting error:
xo.c:11:3: error: (near initialization ‘board[0]’) xo.c:11:3: error: excess elements in char array initializer xo.c:11:3: error: (near initialization ‘board[0]’) xo.c:11:3: error: excess elements in char array initializer xo.c:11:3: error: (near initialization ‘board[1]’) xo.c:11:3: error: excess elements in char array initializer xo.c:11:3: error: (near initialization ‘board[1]’) xo.c:11:3: error: excess elements in char array initializer xo.c:11:3: error: (near initialization ‘board[2]’) xo.c:11:3: error: excess elements in char array initializer xo.c:11:3: error: (near initialization ‘board[2]’)
i initiate 2 dimensional array of 3x3 board. don't understand why there excess, initialized [3][3] , entered 9 elements. here code i've written:
#include<stdio.h> /***** create 2 dimensional array full of blank spaces 1 marks x , 0 marks circle. let use enter coordinates (line , coloumn) placing 1 (x) , automatically print board computers' move. *****/ int = 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"); } }
" "
string (char *
) literal. want ' '
single char
.
change:
char board[3][3] = { {" " , " " , " "} , {" " , " " , " "} , {" " , " " , "t"} };
to:
char board[3][3] = { {' ' , ' ' , ' '} , {' ' , ' ' , ' '} , {' ' , ' ' , 't'} };
Comments
Post a Comment