Basically, in the code below I have a function which initialises a two-dimensional array. In the main function I try to test the function with different sizes of the array. However, I get the following errors: "error: array type has incomplete element type void chessBoard(char board[][], int length, int width)" and "error: type of formal parameter 1 is incomplete". chessBoard(board1, length1, width1);. ANy suggestions?
#include <stdio.h>
#include <stdlib.h>
void chessBoard(char board[][], int length, int width)
{
for (int i = 0; i < length; i++)
{
for (int j = 0; j < width; j++)
if ((i + j) % 2 == 0)
board[i][j] = 'b';
else
board[i][j] = 'w';
}
}
int main()
{
char board1 [3][4];
int length1 = sizeof board1 / sizeof board1[0];
int width1 = sizeof board1[0] / sizeof(int);
chessBoard(board1, length1, width1);
int i, j;
for(i = 0; i < length1; i++)
{
for(j = 0; j < width1; j++)
printf("%c", board1[i][j]);
printf("\n");
}
printf("\n");
}
void chessBoard(char board[][], int length, int width)-->void chessBoard(int width, char board[][width], int length),sizeof(int)-->sizeof(char)int arr[]the compiler treats it asint *arr.