I am creating a 5x5 board game in C. The problem I am having is that when I use the rand() it duplicates some of the numbers. How do I stop the duplicates and 0's?
Sorry if too basic a question. I'm new to C.
int createboard() {
int rows;
int columns;
int board[5][5];
int board2[5][5];
srand(time(NULL));
for (rows = 0; rows < 5; rows++) {
for (columns = 0; columns < 5; columns++) {
randomNumber = rand() % 25;
board[rows][columns] = randomNumber;
}
}
}