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

Discussion in 'C Programming' started by DFouton, Nov 12, 2010.

  1. DFouton

    DFouton

    Joined:
    Nov 12, 2010
    Messages:
    2
    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;
    }
    DFouton, Nov 12, 2010
    #1
    1. Advertising

  2. DFouton

    DFouton

    Joined:
    Nov 12, 2010
    Messages:
    2
    my friend reminded me that arrays dont need pointers. dun and dun. buhbai.
    DFouton, Nov 14, 2010
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michael

    incompatible pointer type warning ?

    Michael, Jun 5, 2006, in forum: C Programming
    Replies:
    8
    Views:
    517
    Ian Collins
    Jun 5, 2006
  2. wanglei0214@gmail.com
    Replies:
    2
    Views:
    1,145
    Ian Collins
    Jul 26, 2006
  3. wanglei0214@gmail.com
    Replies:
    0
    Views:
    1,011
    wanglei0214@gmail.com
    Jul 26, 2006
  4. wanglei0214@gmail.com
    Replies:
    1
    Views:
    496
    Andrew Poelstra
    Jul 26, 2006
  5. PraZ
    Replies:
    6
    Views:
    849
    Gernot Frisch
    Mar 30, 2006
Loading...

Share This Page