I have a couple of errors in my code (which I'll shorten for reading convenience). I think it's merely because I'm still quite new to the way functions are expressed
Code:
void printBoard(int size, int align, int board[size][size]);
int main(int argc, char *argv[]) {
int board[MAX][MAX] = {{}}; // intialized elements to zero
int size = 0;
int align = 0;
printBoard(size, align, board[MAX][MAX]);
return 0;
}
void printBoard(int size, int align, int board[size][size]) {
int i,j;
for (i=0; i<size; i++) {
for (j=0; j<size; j++) {
printf("%*d", align, board[i][j]);
}
}
}
The lines with errors are in red. What am I doing wrong? And in this code I have that size <= MAX depending on the user input for size, so should I be sending board[size][size] to the printBoard function or should I be sending board[MAX][MAX] since my loops are only going to be dealing with a size*size array anyway.
EDIT: The errors I'm getting are,
for first line of error - note: expected ‘int (*)[(unsigned int)(size)]’ but argument is of type ‘int’
second line - error: passing argument 3 of ‘printBoard’ makes pointer from integer without a cast