I've followed steps that were all required so far for a school project and I am getting these two errors ( C++ argument of type "char" is incompatible with parameter of type "char(*)[7]" and 'void boardInit(char [][7])': cannot convert argument 1 from 'char[][7]' ) when trying to call my function to make sure the array is initializing properly. Can anyone tell me why I am getting these errors and how to fix them?
The code below is in a header file.
typedef char Board[BOARD_SIZE][BOARD_SIZE];
void boardInit(Board board);
Both the above definitions were required for the program and can not be changed.
The code below is in my Main.cpp file
int main()
{
Board board;
boardInit(**board**[BOARD_SIZE][BOARD_SIZE]);
}
Above is where I am attempting to call the function (and failing) the errors are coming from the board enclosed in the double stars. (I do not have the stars in the program it's just to point out the problem.
Below is the function I'm looking to implement, it is in yet another file called Board.cpp.
void boardInit(Board board)
{
for (int i = 0; i < BOARD_SIZE; ++i)
{
for (int j = 0; j < BOARD_SIZE; ++j)
{
board[i][j] = 1;
}
}
}
I have all the necessary includes and I can not switch the file they are in because ALL of that information was specified by my professor.
EDIT: We were not provided with a textbook (nor was one even suggested for if we got stuck).
question from:
https://stackoverflow.com/questions/65862347/c-argument-of-type-char-is-incompatible-with-parameter-of-type-char7 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…