I am very new to C and am getting an error and a warning that I am not sure how to fix. I am very prone to problems with declarations and especially the types in declarations so I am fairly sure that is what my problem is. Here is the code:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define BOARD_SIZE 4
void initial_board (char board [], int board_size);
int
main ()
{
char board[BOARD_SIZE][BOARD_SIZE];
initial_board (board, BOARD_SIZE);
return 0;
}
void
initial_board (char board [], int board_size)
{
int i, j;
for (i = 0; i < board_size; i++)
{
for (j = 0; j < board_size; j++)
{
board[i][j] = '.';
}
}
for (i = 0; i < board_size; i++)
{
for (j = 0; j < board_size; j++)
{
printf ("%\t", board[i][j]);
}
printf ("\n");
}
}
What I get when compiling:
warning: passing argument 1 of "initial_board" from incompatible pointer type.
occurs at: initial_board (board, BOARD_SIZE);
note: expected "char *" but argument is of type "char (*)"
occurs at: oid initial_board (char board [], int board_size);
error: subscripted value is neither array nor pointer
occurs at: board[i][j] = '.';
error: subscripted value is neither array nor pointer
occurs at: printf ("%\t", board[i][j]);
Thanks for any help!