I created a function that generates a bingo board and I want to return the bingo board.
as I didn't expect for , it doesn't work.
here is the function:
int** generateBoard() {
int board[N][M], i, j , fillNum;
Boolean exists = True;
// initilize seed
srand(time(NULL));
// fill up..
for(i = 0; i < N; ++i) {
for(j = 0; j < M; ++j) {
exists = True;
while(exists) {
fillNum = rand()%MAX_RANGE + 1; // limit up to MAX_RANGE
if(beenAdded(board, fillNum) == Exist) {
continue;
} else {
board[i][j] = fillNum;
exists = False;
}
}
}
}
return board;
}
I have a compilcation error (the red subline) at "return board" line.
is there way to return a 2D array without using structs dynamic allocations?
I'm using Microsoft Visual C++ Express 2010.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…