void generalboard();
void inputuser(int*pt1, int*pt2,int*pt3);
void checkwins1d(int*A,int*B, char C[][3][3]);
void checkwinsup(int*A,int*B,char C[][3][3]);
void checkwins3D(int*A,int*B,char C[][3][3]);
void inputcomputer(int*pt1,int*pt2,int*pt3,char A[][3][3]);
void score (int a, int b);
void displayboard(int a, int b, int c, int i, int j, int k, char board [][3][3]);


int main () {
int i,j,k,a,b,c,computerscore=0,userscore=0,counter=0;
char board[3][3][3];

generalboard();
inputuser(&i,&j,&k);
inputcomputer(&a,&b,&c,board[3][3][3]);
displayboard(a,b,c,i,j,k,board[3][3][3]);
while (counter<=27){
inputuser(&i,&j,&k);
counter++;
inputcomputer(&a,&b,&c, board[3][3][3]);
counter++;
displayboard(a,b,c,i,j,k,board[3][3][3]);
checkwins1d(&userscore,&computerscore,board[3][3][3]);
checkwinsup(&userscore,&computerscore, board[3][3][3]);
checkwins3D(&userscore,&computerscore,board[3][3][3]);
score(computerscore, userscore);
}
if (computerscore> userscore) printf("Computer is the winner.\n");
else if (computerscore<userscore) printf ("Congrats, you won!\n");
else printf("it is a draw.\n");
return 0;
}

This is a 3D TTT game program... for all the function that contains a 3d array, it always show that there is an incompatible pointer...
I tried the following possibilities:
void inputcomputer(int*pt1,int*pt2,int*pt3,char *A);

int main{
//assumed I declared all the int and char)

inputcomputer(a,b,c,char A[][3][3]);// but it doesn't seem to work and still show the same error...

Edited 5 Years Ago by __avd: Added [code] tags.

inputcomputer(a,b,c,char A[][3][3]);

You should not declare the array while passing the values because it would give you errors.Declare the array before passing it.

char A[][3][3];
inputcomputer(a,b,c,A);

In the function prototype A is declared as a char *. It can only hold one string.

void inputcomputer(int*pt1,int*pt2,int*pt3,char *A);

Declare A as char *A[3][3] or as char **A[3] according to your convenience.

Use CODE TAGS while posting.

Edited 5 Years Ago by Arbus: n/a

hmm... I tried...this is what I have now...
Prototype:

void generalboard();
void inputuser(int*pt1, int*pt2,int*pt3);
void checkwins1d(int*A,int*B, char*C);
void checkwinsup(int*A,int*B,char *C);
void checkwins3D(int*A,int*B,char *C);
void inputcomputer(int*pt1,int*pt2,int*pt3,char *A);
void score (int a, int b);
void displayboard(int a, int b, int c, int i, int j, int k, char *board);

Body:

char board[3][3][3];
generalboard();
inputuser(&i,&j,&k);
inputcomputer(&a,&b,&c,board);
displayboard(a,b,c,i,j,k,board);

same problem still applies... it says the fourth arguments (the 3-D arrays are incompatible prototype)

You didn't read my previous post properly.

void inputcomputer(int*pt1,int*pt2,int*pt3,char *A);

You have declared A as char *, it can hold only a string (like 1D array). But you are passing multidimensional array. So declare A accordingly (char **A[3] or char *A[3][3]).
example,

void inputcomputer(int*pt1,int*pt2,int*pt3,char *A[3][3]);

It seems Arbus is more confused about multi-dimension arrays than you are.

> But you are passing multidimensional array. So declare A accordingly (char **A[3] or char *A[3][3]).
But neither of these things are anywhere near char A[][3][3], which is what the OP had to begin with. char (*A)[3][3] would have been OK, but your permutations didn't go that far.


All that was needed was fixing how to pass the array parameter to the function in the first instance. Everything else was OK.

#include <stdio.h>

void displayboard(char board[][3][3]);

int main()
{
  char board[3][3][3] = {
    {
      { "123" },
      { "456" },
      { "789" },
    },
    {
      { "ABC" },
      { "DEF" },
      { "GHI" },
    },
    {
      { "!%^" },
      { "&()" },
      { "+-=" },
    },
  };
  displayboard(board);  //!! No *, & or subscripts here!!
  return 0;
}

void displayboard(char board[][3][3]) {
  int i, j, k;
  for ( i = 0 ; i < 3 ; i++ ) {
    for ( j = 0 ; j < 3 ; j++ ) {
      for ( k = 0 ; k < 3 ; k++ ) {
        printf("%c ", board[i][j][k] );
      }
      printf("\n");
    }
    printf("---\n");
  }
}

Not a single * to be seen!

It seems Arbus is more confused about multi-dimension arrays than you are.

> But you are passing multidimensional array. So declare A accordingly (char **A[3] or char *A[3][3]).
But neither of these things are anywhere near char A[][3][3], which is what the OP had to begin with. char (*A)[3][3] would have been OK, but your permutations didn't go that far.


All that was needed was fixing how to pass the array parameter to the function in the first instance. Everything else was OK.

#include <stdio.h>

void displayboard(char board[][3][3]);

int main()
{
  char board[3][3][3] = {
    {
      { "123" },
      { "456" },
      { "789" },
    },
    {
      { "ABC" },
      { "DEF" },
      { "GHI" },
    },
    {
      { "!%^" },
      { "&()" },
      { "+-=" },
    },
  };
  displayboard(board);  //!! No *, & or subscripts here!!
  return 0;
}

void displayboard(char board[][3][3]) {
  int i, j, k;
  for ( i = 0 ; i < 3 ; i++ ) {
    for ( j = 0 ; j < 3 ; j++ ) {
      for ( k = 0 ; k < 3 ; k++ ) {
        printf("%c ", board[i][j][k] );
      }
      printf("\n");
    }
    printf("---\n");
  }
}

Not a single * to be seen!

that's what I had in mind...however, I am also passing on the three integers with three integer pointers...does it matter?

really helpful guys...I am almost there I can feel it.

Oops!Sorry That was really a mistake. Forgive me please

Edited 5 Years Ago by Arbus: n/a

This article has been dead for over six months. Start a new discussion instead.