expression must be a pointer to a complete object type

c, multidimensional-array, pointers

Solution

Apart from the fact that `&board[r][c]` is of type `struct piece *` and not `struct piece` you also need to include the header file which defines `piece`. The compiler is telling you that it has not enough information about `struct piece`.

Problem

I'm trying to access the values of a multidimensional array with two integers. The array is declared in another source file. I'm using an extern declaration at the top of the problem source file. In the file where it's declared, I can access the values. However, when I copy and paste the same line of code over, the compiler informs me that the expression must be a pointer to a complete object type. I'm new to C and pointers, so I don't really know what's going on. I would appreciate any ideas. ``` extern struct piece board[8][8]; void move() { char row; int column; int rowNumber = 0; printf("row: "); scanf("%c",&row); fflush(stdin); printf("column: "); scanf("%d",&column); column--; switch(row) { case 'A': rowNumber = 0; break; case 'B': rowNumber = 1; break; case 'C': rowNumber = 2; break; case 'D': rowNumber = 3; break; case 'E': rowNumber = 4; break; case 'F': rowNumber = 5; break; case 'G': rowNumber = 6; break; case 'H': rowNumber = 7; } printf("\n your row is %d and column is %d",rowNumber,column); struct piece temp = &board[rowNumber][column]; } ``` and the array itself: ``` struct piece board[8][8] = {{{0,0,blackRook,"Rook"},{0,1,blackKnight,"Knight"}, {0,2,blackBishop,"Bishop"},{0,3,blackQueen,"Queen"},{0,4,blackKing,"King"}, {0,5,blackBishop,"Bishop"},{0,6,blackKnight,"Knight"},{0,7,blackRook,"Rook"}}, {{1,0,blackPawn,"Pawn"}, {1,1,blackPawn,"Pawn"},{1,2,blackPawn,"Pawn"},{1,3,blackPawn,"Pawn"},{1,4,blackPawn,"Pawn"},{1,5,blackPawn,"Pawn"},{1,6,blackPawn,"Pawn"},{1,7,blackPawn,"Pawn"}}, {0},{0},{0},{0}, {{6,0,whitePawn,"Pawn"},{6,1,whitePawn,"Pawn"},{6,2,whitePawn,"Pawn"},{6,3,whitePawn,"Pawn"},{6,4,whitePawn,"Pawn"},{6,5,whitePawn,"Pawn"},{6,6,whitePawn,"Pawn"},{6,7,whitePawn,"Pawn"}}, {{7,0,whiteRook,"Rook"},{7,1,whiteKnight,"Knight"},{7,2,whiteBishop,"Bishop"},{7,3,whiteQueen,"Queen"},{7,4,whiteKing,"King"},{7,5,whiteBishop,"Bishop"},{7,6,whiteKnight,"Knight"},{7,7,whiteRook,"Rook"}}}; ``` Sorry about the formatting, it looks better in Visual Studio. The first two and last two arrays are filled with the struct piece - and the rest is 0. The empty values don't seem to be causing any problems anywhere else in my code. EDIT - here is the piece definition: ``` struct piece { int row; int column; int weight; char name[20]; }; ```

Original source