warning: passing argument 1 of 'play' from incompatible pointer type

Joined
Nov 12, 2010
Messages
2
Reaction score
0
Hey, I'm trying to program a tic tac toe game to the specifications of my professor, and im having an issue with pointers and 2D arrays. Anyone know what is wrong with this program (dont worry about the fact that i didnt use #include to load some stuff, this is only a portion of the program)

If you can help me please post a response in a simple explination that doesnt go into technical terms. I know basics about this language but i dont know everything.

The warning happens in the main function, when i use the function 'play'. Something isnt working with my 2D array being used with pointers.


void play (char *board[3][3], int *player)
{
int x,y = 0;
do
{
printf("Player %d: choose a location: (x, then y)", *player);
scanf("%d %d", &x, &y);
if (*board[x][y] != ' ')
printf("Location already occupied\n");
}
while (*board[x][y]!=' ');
if (*player = 1)
*board[x-1][y-1]='X';
else if (*player = 2)
*board[x-1][y-1]='O';
else
*board[x-1][y-1]='?';
}


int main()
{
char board[3][3];
int i,l;
for (i = 0; i < 3; i++)
for (l = 0; l <3;l++)
board[l]='?';
int player = 1;
play (&board,&player);
return 0;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top